home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1994 November / Cd Ware (Nro. 2) - Epimundo.iso / OS2 / PC2_170.ZIP / SOURCE.ZIP / Source / Dialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-01  |  118.4 KB  |  2,085 lines

  1. /***********************************************************************\
  2.  *                                PC2.c                                *
  3.  *              Copyright (C) by Stangl Roman, 1993, 1994              *
  4.  * This Code may be freely distributed, provided the Copyright isn't   *
  5.  * removed, under the conditions indicated in the documentation.       *
  6.  *                                                                     *
  7.  * Dialog.c     Dialog window procedures.                              *
  8.  *                                                                     *
  9. \***********************************************************************/
  10.  
  11. static char RCSID[]="@(#) $Header: Dialog.c Version 1.70 06,1994 $ (LBL)";
  12.  
  13. #define         _FILE_  "PC/2 - Dialog.c V1.70"
  14.  
  15. #include        "PC2.h"                 /* User include files */
  16. #include        "Error.h"
  17.  
  18. PFNWP           PI_ClassDialogProcedure;
  19.  
  20.                                         /* Program Installation dialog notebook pages */
  21. NBPAGE          nbPINotebookPage[]=
  22. {
  23.     {PI_NotebookProcedure,  0,  0,  "Application Settings", "~Application", PIID_PAGE1, PIEF_PROGRAMTITLE},
  24.     {PI_NotebookProcedure,  0,  0,  "Session Settings",     "~Session",     PIID_PAGE2, PIRB_SHELL},
  25.     {PI_NotebookProcedure,  0,  0,  "Style Settings",       "S~tyle",       PIID_PAGE3, PIRB_DEFAULTSTYLE},
  26.     {PI_NotebookProcedure,  0,  0,  "Hotkey Settings",      "~Hotkey",      PIID_PAGE4, PIRB_WSMAXIMIZED},
  27.     {PI_NotebookProcedure,  0,  0,  "Priority Settings",    "~Priority",    PIID_PAGE5, PIRB_NOCHANGE},
  28.     {NULL,                  0,  0,  "",                     "",             0,          0}
  29. };
  30.  
  31. /*--------------------------------------------------------------------------------------*\
  32.  * This dialog procedure handles the PC/2 - About dialog.                               *
  33.  * Req: none                                                                            *
  34. \*--------------------------------------------------------------------------------------*/
  35. MRESULT  EXPENTRY AD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  36. {
  37. switch(msg)
  38. {
  39. case WM_INITDLG:
  40.     {
  41.     SWP         swp;
  42.  
  43.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  44.     WinQueryWindowPos(                  /* Query position of dialog window */
  45.         hwndDlg,                        /* Handle of dialog window */
  46.         &swp);                          /* Fill with position */
  47.     WinSetWindowPos(                    /* Set dialog window position */
  48.         hwndDlg,                        /* Handle of dialog window */
  49.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  50.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  51.     break;
  52.     }
  53.  
  54. case WM_HELP:                           /* Help pressed */
  55.     if(hwndHelp!=NULLHANDLE) WinSendMsg(
  56.         hwndHelp,                       /* Help window */
  57.         HM_DISPLAY_HELP,                /* Display a help panel */
  58.         MPFROMSHORT(ID_ABOUTDIALOG),    /* Panel ID in ressource file */
  59.         HM_RESOURCEID);                 /* MP1 points to the help window identity */
  60.     break;
  61.  
  62. case WM_COMMAND:                        /* Button pressed */
  63.     switch(SHORT1FROMMP(mp1))
  64.     {
  65.     case DID_OK:                        /* Enter key pressed */
  66.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  67.         break;
  68.  
  69.     case DID_CANCEL:                    /* Cancel key pressed */
  70.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  71.         break;
  72.  
  73.     default:
  74.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  75.     }
  76.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  77.     break;
  78.  
  79. default:                                /* Default window procedure must be called */
  80.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  81. }
  82. return((MRESULT)FALSE);                 /* We have handled the message */
  83. }
  84.  
  85. /*--------------------------------------------------------------------------------------*\
  86.  * This dialog procedure handles the PC/2 - Desktop configuration dialog.               *
  87.  * Req: none                                                                            *
  88. \*--------------------------------------------------------------------------------------*/
  89. MRESULT  EXPENTRY DD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  90. {
  91.                                         /* Child windows that change with the
  92.                                            DDCD_SLIDINGFOCUS checkbox */
  93. static USHORT   usChild2SlidingFocusCB[]={DDCB_PRESERVEZORDER};
  94.                                         /* Child windows that change with the
  95.                                            DDCB_VIRTUALDESKTOP checkbox */
  96. static USHORT   usChild2VirtualDesktopCB[]={DDCB_MOVEDESKTOP, DDCB_CLICK2MOVE,
  97.                                             DDCB_OVERVIEW, DDCB_KEEPONTOP, DDEF_SCROLLPERCENTAGE};
  98. UCHAR       ucBuffer[4];
  99.  
  100. switch(msg)
  101. {
  102. case WM_INITDLG:
  103.     {
  104.     SWP         swp;
  105.  
  106.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  107.     WinQueryWindowPos(                  /* Query position of dialog window */
  108.         hwndDlg,                        /* Handle of dialog window */
  109.         &swp);                          /* Fill with position */
  110.     WinSetWindowPos(                    /* Set dialog window position */
  111.         hwndDlg,                        /* Handle of dialog window */
  112.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  113.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  114. /*                                                                                      *\
  115.  * Check the checkboxes that should be set according to the bitmap currently used in    *
  116.  * PC2.INI. If the virtual Desktop is disabled, then its child checkboxes can't be set, *
  117.  * because unchecking the virtual Desktop automatically unchecks its child checkboxes.  *
  118. \*                                                                                      */
  119.                                         /* Check ckeckbox if sliding focus flag is set */
  120.     if(HookParameters.ulStatusFlag & SLIDINGFOCUS)
  121.         WinSendDlgItemMsg(hwndDlg, DDCB_SLIDINGFOCUS, BM_SETCHECK,
  122.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  123.                                         /* Check ckeckbox if preserve z-order flag is set */
  124.     if(HookParameters.ulStatusFlag & PRESERVEZORDER)
  125.         WinSendDlgItemMsg(hwndDlg, DDCB_PRESERVEZORDER, BM_SETCHECK,
  126.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  127.                                         /* Check ckeckbox if button 2 z-order flag is set */
  128.     if(HookParameters.ulStatusFlag & BUTTON2ZORDER)
  129.         WinSendDlgItemMsg(hwndDlg, DDCB_BUTTON2ZORDER, BM_SETCHECK,
  130.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  131.                                         /* Check checkbox if virtual Desktop flag is set */
  132.     if(HookParameters.ulStatusFlag & VIRTUALDESKTOP)
  133.         WinSendDlgItemMsg(hwndDlg, DDCB_VIRTUALDESKTOP, BM_SETCHECK,
  134.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  135.                                         /* Check checkbox if keep on top flag is set */
  136.     if(HookParameters.ulStatusFlag & KEEPONTOP)
  137.         WinSendDlgItemMsg(hwndDlg, DDCB_KEEPONTOP, BM_SETCHECK,
  138.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  139.                                         /* Check checkbox if move Desktop flag is set */
  140.     if(HookParameters.ulStatusFlag & MOVEDESKTOP)
  141.         WinSendDlgItemMsg(hwndDlg, DDCB_MOVEDESKTOP, BM_SETCHECK,
  142.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  143.                                         /* Check checkbox if click to move flag is set */
  144.     if(HookParameters.ulStatusFlag & CLICK2MOVE)
  145.         WinSendDlgItemMsg(hwndDlg, DDCB_CLICK2MOVE, BM_SETCHECK,
  146.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  147.                                         /* Check checkbox if overview window flag is set */
  148.     if(HookParameters.ulStatusFlag & OVERVIEW)
  149.         WinSendDlgItemMsg(hwndDlg, DDCB_OVERVIEW, BM_SETCHECK,
  150.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  151. /*                                                                                      *\
  152.  * Write the Desktop and Window List currently available or the default ones from       *
  153.  * PC2.INI into the entryfields. The maximum length of both we assume MAXNAMEL.         *
  154. \*                                                                                      */
  155.                                         /* First set the limits to MAXNAMEL */
  156.     WinSendDlgItemMsg(hwndDlg, DDEF_DESKTOPNAME, EM_SETTEXTLIMIT,
  157.         MPFROMSHORT(MAXNAMEL), (MPARAM)NULL);
  158.     WinSendDlgItemMsg(hwndDlg, DDEF_WINDOWLISTNAME, EM_SETTEXTLIMIT,
  159.         MPFROMSHORT(MAXNAMEL), (MPARAM)NULL);
  160.                                         /* Insert the strings */
  161.     WinSetDlgItemText(hwndDlg, DDEF_DESKTOPNAME, HookParameters.ucDesktopName);
  162.     WinSetDlgItemText(hwndDlg, DDEF_WINDOWLISTNAME, HookParameters.ucWindowListName);
  163. /*                                                                                      *\
  164.  * Set scrolling percentage entryfield and horizontal scrollbar in 5 % increments.      *
  165. \*                                                                                      */
  166.     WinSendDlgItemMsg(hwndDlg, DDHSB_SCROLLPERCENTAGE,
  167.         SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 20), (MPARAM)NULL);
  168.     WinSendDlgItemMsg(hwndDlg, DDHSB_SCROLLPERCENTAGE,
  169.         SBM_SETSCROLLBAR, MPFROMSHORT(HookParameters.ulScrollPercentage/5),
  170.         MPFROM2SHORT(0, 20));
  171.                                         /* Insert the string */
  172.     WinSetDlgItemText(hwndDlg, DDEF_SCROLLPERCENTAGE,
  173.         (CHAR *)_itoa(HookParameters.ulScrollPercentage, ucBuffer, 10));
  174. /*                                                                                      *\
  175.  * Disable the child windows of the sliding Focus, if this checkbox isn't checked.      *
  176. \*                                                                                      */
  177.     if(!(HookParameters.ulStatusFlag & SLIDINGFOCUS))
  178.         DisableDialogItem(hwndDlg, usChild2SlidingFocusCB,
  179.             sizeof(usChild2SlidingFocusCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  180. /*                                                                                      *\
  181.  * Disable the child windows of the virtual Desktop, if this checkbox isn't checked.    *
  182. \*                                                                                      */
  183.     if(!(HookParameters.ulStatusFlag & VIRTUALDESKTOP))
  184.         DisableDialogItem(hwndDlg, usChild2VirtualDesktopCB,
  185.             sizeof(usChild2VirtualDesktopCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  186. /*                                                                                      *\
  187.  * Set click flag.                                                                      *
  188. \*                                                                                      */
  189.     if(HookParameters.ulClickFlag==WM_BUTTON1CLICK)
  190.         WinSendDlgItemMsg(hwndDlg, DDRB_BUTTON1CLICK, BM_SETCHECK,
  191.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  192.     else
  193.         WinSendDlgItemMsg(hwndDlg, DDRB_BUTTON1DBLCLK, BM_SETCHECK,
  194.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  195.     break;
  196.     }
  197.  
  198. case WM_HELP:                           /* Help pressed */
  199.     if(hwndHelp!=NULLHANDLE) WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
  200.         MPFROMSHORT(ID_DESKTOPDIALOG), HM_RESOURCEID);
  201.     break;
  202.  
  203. case WM_HSCROLL:                        /* Messages generated by horizontal scrollbars */
  204. /*                                                                                      *\
  205.  * This message is generated when a horizontal scrollbar is manipulated. See if it is   *
  206.  * our scrollbar DDHSB_SCROLLPERCENTAGE and process.                                    *
  207. \*                                                                                      */
  208.     if(SHORT1FROMMP(mp1)==DDHSB_SCROLLPERCENTAGE)
  209.         {
  210.         SHORT       sSliderPosition=SHORT1FROMMP(mp2);;
  211.  
  212.         switch(SHORT2FROMMP(mp2))
  213.         {                               /* All messages contain the new slider position,
  214.                                            so just use this value to change the priority
  215.                                            delta entryfield value */
  216.         case SB_LINELEFT:
  217.             HookParameters.ulScrollPercentage-=5;
  218.             break;
  219.  
  220.         case SB_PAGELEFT:
  221.             HookParameters.ulScrollPercentage-=25;
  222.             break;
  223.  
  224.         case SB_LINERIGHT:
  225.             HookParameters.ulScrollPercentage+=5;
  226.             break;
  227.  
  228.         case SB_PAGERIGHT:
  229.             HookParameters.ulScrollPercentage+=25;
  230.             break;
  231.  
  232.         case SB_SLIDERTRACK:
  233.         case SB_SLIDERPOSITION:
  234.             HookParameters.ulScrollPercentage=sSliderPosition*5;
  235.             break;
  236.         }
  237.         if(((LONG)HookParameters.ulScrollPercentage)<0) HookParameters.ulScrollPercentage=0;
  238.         if(HookParameters.ulScrollPercentage>100) HookParameters.ulScrollPercentage=100;
  239.         WinSetDlgItemText(hwndDlg, DDEF_SCROLLPERCENTAGE,
  240.             (CHAR *)_itoa(HookParameters.ulScrollPercentage, ucBuffer, 10));
  241.         WinSendDlgItemMsg(hwndDlg, DDHSB_SCROLLPERCENTAGE,
  242.             SBM_SETPOS, MPFROMSHORT(HookParameters.ulScrollPercentage/5), (MPARAM)NULL);
  243.         }
  244.     break;
  245.  
  246. case WM_CONTROL:                        /* Test for checkbuttons buttons pressed */
  247. /*                                                                                      *\
  248.  * Only if the DDCB_VIRTUALDESKTOP checkbox is pressed, its child windows are to be     *
  249.  * enabled. Otherwise the are disabled, but allways visible.                            *
  250. \*                                                                                      */
  251.     {
  252.     if(SHORT2FROMMP(mp1)==BN_CLICKED)   /* Was autoradio button clicked ? */
  253.         switch(SHORT1FROMMP(mp1))
  254.         {
  255.         case DDCB_SLIDINGFOCUS:         /* Sliding Focus enable/disable checkbox */
  256.             if((BOOL)WinSendDlgItemMsg(hwndDlg, DDCB_SLIDINGFOCUS, BM_QUERYCHECK,
  257.                 (MPARAM)NULL, (MPARAM)NULL)==TRUE)
  258.                                         /* Enable and show SlidingFocusCB child windows */
  259.                 DisableDialogItem(hwndDlg, usChild2SlidingFocusCB,
  260.                     sizeof(usChild2SlidingFocusCB)/sizeof(USHORT), WS_VISIBLE);
  261.             else
  262.                 {                       /* If preserve Z-order is checked, uncheck it */
  263.                 if(WinQueryButtonCheckstate(hwndDlg, DDCB_PRESERVEZORDER))
  264.                     WinSendDlgItemMsg(hwndDlg, DDCB_PRESERVEZORDER, BM_SETCHECK,
  265.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  266.                                         /* Disable and show SlidingFocusCB child windows */
  267.                 DisableDialogItem(hwndDlg, usChild2SlidingFocusCB,
  268.                     sizeof(usChild2SlidingFocusCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  269.                 }
  270.             break;
  271.  
  272.         case DDCB_VIRTUALDESKTOP:       /* Virtal Desktop enable/disable checkbox */
  273.             if((BOOL)WinSendDlgItemMsg(hwndDlg, DDCB_VIRTUALDESKTOP, BM_QUERYCHECK,
  274.                 (MPARAM)NULL, (MPARAM)NULL)==TRUE)
  275.                                         /* Enable and show VirtualDesktopCB child windows */
  276.                 DisableDialogItem(hwndDlg, usChild2VirtualDesktopCB,
  277.                     sizeof(usChild2VirtualDesktopCB)/sizeof(USHORT), WS_VISIBLE);
  278.             else
  279.                 {
  280.                                         /* If move Desktop checkbox is checked, uncheck it */
  281.                 if(WinQueryButtonCheckstate(hwndDlg, DDCB_MOVEDESKTOP))
  282.                     WinSendDlgItemMsg(hwndDlg, DDCB_MOVEDESKTOP, BM_SETCHECK,
  283.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  284.                                         /* If click to move checkbox is checked, uncheck it */
  285.                 if(WinQueryButtonCheckstate(hwndDlg, DDCB_CLICK2MOVE))
  286.                     WinSendDlgItemMsg(hwndDlg, DDCB_CLICK2MOVE, BM_SETCHECK,
  287.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  288.                                         /* If overview checkbox is checked, uncheck it */
  289.                 if(WinQueryButtonCheckstate(hwndDlg, DDCB_OVERVIEW))
  290.                     WinSendDlgItemMsg(hwndDlg, DDCB_OVERVIEW, BM_SETCHECK,
  291.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  292.                                         /* If keep on top checkbox is checked, uncheck it */
  293.                 if(WinQueryButtonCheckstate(hwndDlg, DDCB_KEEPONTOP))
  294.                     WinSendDlgItemMsg(hwndDlg, DDCB_KEEPONTOP, BM_SETCHECK,
  295.                     MPFROMSHORT(FALSE), (MPARAM)NULL);
  296.                 DisableDialogItem(hwndDlg, usChild2VirtualDesktopCB,
  297.                     sizeof(usChild2VirtualDesktopCB)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  298.                 }
  299.             break;
  300.         }
  301.     }
  302.     break;
  303.  
  304. case WM_COMMAND:                        /* Button pressed */
  305.     switch(SHORT1FROMMP(mp1))
  306.     {
  307.     case DID_OK:                        /* Enter key pressed */
  308.                                         /* Query checkboxes' state and set according flag */
  309.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_SLIDINGFOCUS))
  310.             HookParameters.ulStatusFlag|=SLIDINGFOCUS;
  311.         else HookParameters.ulStatusFlag&=~SLIDINGFOCUS;
  312.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_PRESERVEZORDER))
  313.             HookParameters.ulStatusFlag|=PRESERVEZORDER;
  314.         else HookParameters.ulStatusFlag&=~PRESERVEZORDER;
  315.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_BUTTON2ZORDER))
  316.             HookParameters.ulStatusFlag|=BUTTON2ZORDER;
  317.         else HookParameters.ulStatusFlag&=~BUTTON2ZORDER;
  318.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_VIRTUALDESKTOP))
  319.             HookParameters.ulStatusFlag|=VIRTUALDESKTOP;
  320.         else HookParameters.ulStatusFlag&=~VIRTUALDESKTOP;
  321.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_KEEPONTOP))
  322.             HookParameters.ulStatusFlag|=KEEPONTOP;
  323.         else HookParameters.ulStatusFlag&=~KEEPONTOP;
  324.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_MOVEDESKTOP))
  325.             HookParameters.ulStatusFlag|=MOVEDESKTOP;
  326.         else HookParameters.ulStatusFlag&=~MOVEDESKTOP;
  327.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_CLICK2MOVE))
  328.             HookParameters.ulStatusFlag|=CLICK2MOVE;
  329.         else HookParameters.ulStatusFlag&=~CLICK2MOVE;
  330.         if(WinQueryButtonCheckstate(hwndDlg, DDCB_OVERVIEW))
  331.             HookParameters.ulStatusFlag|=OVERVIEW;
  332.         else HookParameters.ulStatusFlag&=~OVERVIEW;
  333.                                         /* Query Desktop and Window List name */
  334.         WinQueryWindowText(WinWindowFromID(hwndDlg, DDEF_DESKTOPNAME),
  335.             sizeof(HookParameters.ucDesktopName), HookParameters.ucDesktopName);
  336.         WinQueryWindowText(WinWindowFromID(hwndDlg, DDEF_WINDOWLISTNAME),
  337.             sizeof(HookParameters.ucWindowListName), HookParameters.ucWindowListName);
  338.                                         /* Query scroll percentage listbox (0-based !!!) */
  339.         WinQueryWindowText(WinWindowFromID(hwndDlg, DDEF_SCROLLPERCENTAGE),
  340.             sizeof(ucBuffer), ucBuffer);
  341.         HookParameters.ulScrollPercentage=(ULONG)atol(ucBuffer);;
  342.                                         /* Reinitialize scroll percentage */
  343.         HookParameters.SlidingXFactor=(HookParameters.ulScrollPercentage*
  344.             HookParameters.DesktopSize.x)/100;
  345.         HookParameters.SlidingYFactor=(HookParameters.ulScrollPercentage*
  346.             HookParameters.DesktopSize.y)/100;
  347.                                         /* Query click flag */
  348.         if(WinQueryButtonCheckstate(hwndDlg, DDRB_BUTTON1CLICK))
  349.             HookParameters.ulClickFlag=WM_BUTTON1CLICK;
  350.         else HookParameters.ulClickFlag=WM_BUTTON1DBLCLK;
  351.                                         /* Show or hide overview window according to
  352.                                            the user selected flag */
  353.         if(HookParameters.ulStatusFlag & OVERVIEW)
  354.             WinSetWindowPos(hwndFrame, HWND_BOTTOM, 0, 0, 0, 0, SWP_SHOW | SWP_DEACTIVATE);
  355.         else
  356.             WinSetWindowPos(hwndFrame, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDE | SWP_DEACTIVATE);
  357.                                         /* Write changes to PC2.INI */
  358.         INIAccess(pucFilenameINI, FALSE);
  359.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  360.         break;
  361.  
  362.     case DID_CANCEL:                    /* Cancel key pressed */
  363.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  364.         break;
  365.  
  366.     default:
  367.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  368.     }
  369.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  370.     break;
  371.  
  372. default:                                /* Default window procedure must be called */
  373.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  374. }
  375. return((MRESULT)FALSE);                 /* We have handled the message */
  376. }
  377.  
  378.  
  379. /*--------------------------------------------------------------------------------------*\
  380.  * This dialog procedure handles the PC/2 - Program Installation dialog notebook pages. *
  381.  * Req:                                                                                 *
  382.  *      nbPINotebookPage[] ...  Structure of the Program Installtion notebook pages     *
  383. \*--------------------------------------------------------------------------------------*/
  384. MRESULT  EXPENTRY PI_NotebookProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  385. {
  386. static SHORT    sPriorityDelta=PRTYC_NOCHANGE;
  387.  
  388. switch(msg)
  389. {
  390. /*                                                                                      *\
  391.  * Syntax: WM_SETUPNOTEBOOKPAGES, NULL, NULL                                            *                                           *
  392. \*                                                                                      */
  393. case WM_SETUPNOTEBOOKPAGES:
  394.     {
  395. /*                                                                                      *\
  396.  * Set the maximum number of chars accepted from the entryfield (thus overwriting the   *
  397.  * default number of 63 and load the data from the SESSIONDATA structure SessionData    *
  398.  * into the entryfields.                                                                *
  399. \*                                                                                      */
  400.     WinSendDlgItemMsg(                  /* Send message to dialog window */
  401.                                         /* Handle of page 1 */
  402.         nbPINotebookPage[PAGE_1].hwndPINBPage,
  403.         PIEF_PROGRAMTITLE,              /* Program title entryfield */
  404.         EM_SETTEXTLIMIT,                /* Set text limit to 60 */
  405.         MPFROMSHORT(MAXNAMEL),
  406.         (MPARAM)NULL);                  /* No additional parameter */
  407.     WinSetDlgItemText(                  /* Load the default text of the entryfield */
  408.         nbPINotebookPage[PAGE_1].hwndPINBPage, PIEF_PROGRAMTITLE, SessionData.PgmTitle);
  409.     WinSendDlgItemMsg(
  410.         nbPINotebookPage[PAGE_1].hwndPINBPage,
  411.         PIEF_PATHFILENAME,              /* Path and Filename title entryfield */
  412.         EM_SETTEXTLIMIT,                /* Set text limit to 255 */
  413.         MPFROMSHORT(EF_SIZE255),
  414.         (MPARAM)NULL);
  415.     WinSetDlgItemText(nbPINotebookPage[PAGE_1].hwndPINBPage, PIEF_PATHFILENAME, SessionData.PgmName);
  416.     WinSendDlgItemMsg(
  417.         nbPINotebookPage[PAGE_1].hwndPINBPage,
  418.         PIEF_DIRECTORY,                 /* Working directory entryfield */
  419.         EM_SETTEXTLIMIT,                /* Set text limit to 255 */
  420.         MPFROMSHORT(EF_SIZE255),
  421.         (MPARAM)NULL);
  422.     WinSetDlgItemText(nbPINotebookPage[PAGE_1].hwndPINBPage, PIEF_DIRECTORY, SessionData.PgmDirectory);
  423.     WinSendDlgItemMsg(
  424.         nbPINotebookPage[PAGE_1].hwndPINBPage,
  425.         PIEF_PARAMETERS,                /* Program Parameters entryfield */
  426.         EM_SETTEXTLIMIT,                /* Set text limit to 255 */
  427.         MPFROMSHORT(EF_SIZE255),
  428.         (MPARAM)NULL);
  429.     WinSetDlgItemText(nbPINotebookPage[PAGE_1].hwndPINBPage, PIEF_PARAMETERS, SessionData.PgmInputs);
  430.                                         /* Insert DOS Settings. If none exist add the
  431.                                            IDLE_* default settings */
  432.     if(strlen(SessionData.PgmDosSettings)!=0)
  433.         WinSendDlgItemMsg(
  434.             nbPINotebookPage[PAGE_1].hwndPINBPage,
  435.             PIMLE_DOSSETTINGS,          /* Program DOS Settings entryfield */
  436.             MLM_INSERT,                 /* Insert text */
  437.             MPFROMP(SessionData.PgmDosSettings),
  438.             (MPARAM)NULL);
  439.     else
  440.         WinSendDlgItemMsg(
  441.             nbPINotebookPage[PAGE_1].hwndPINBPage,
  442.             PIMLE_DOSSETTINGS,          /* Program DOS Settings entryfield */
  443.             MLM_INSERT,                 /* Insert text */
  444.             MPFROMP("IDLE_SECONDS=5\nIDLE_SENSITIVITY=100\n"),
  445.             (MPARAM)NULL);
  446. /*                                                                                      *\
  447.  * Now we preselect the radiobutton in the Program type group to the state indicated by *
  448.  * the SessionData structure.                                                           *
  449. \*                                                                                      */
  450.     WinSendMsg(hwndDlg, WM_SETUPPROGRAMTYPE,
  451.         MPFROMSHORT(SessionData.SessionType), (MPARAM)NULL);
  452. /*                                                                                      *\
  453.  * Now we preselect the radiobutton in the Program style group to the state indicated   *
  454.  * by the SessionData structure.                                                        *
  455. \*                                                                                      */
  456.     if(!(SessionData.PgmControl & (SSF_CONTROL_MAXIMIZE | SSF_CONTROL_MINIMIZE)))
  457.         WinSendDlgItemMsg(              /* Send message to Default radiobutton */
  458.                                         /* Handle of dialog window */
  459.             nbPINotebookPage[PAGE_3].hwndPINBPage,
  460.             PIRB_DEFAULTSTYLE,          /* Program style: Default radiobutton */
  461.             BM_SETCHECK,                /* Set it to pressed */
  462.             MPFROMSHORT(TRUE),
  463.             (MPARAM)NULL);
  464.     if(SessionData.PgmControl & SSF_CONTROL_MAXIMIZE)
  465.         WinSendDlgItemMsg(
  466.             nbPINotebookPage[PAGE_3].hwndPINBPage,
  467.             PIRB_MAXIMIZED,             /* Program style: Maximized radiobutton */
  468.             BM_SETCHECK,                /* Set it to pressed */
  469.             MPFROMSHORT(TRUE),
  470.             (MPARAM)NULL);
  471.     if(SessionData.PgmControl & SSF_CONTROL_MINIMIZE)
  472.         WinSendDlgItemMsg(
  473.             nbPINotebookPage[PAGE_3].hwndPINBPage,
  474.             PIRB_MINIMIZED,             /* Program style: Minimized radiobutton */
  475.             BM_SETCHECK,                /* Set it to pressed */
  476.             MPFROMSHORT(TRUE),
  477.             (MPARAM)NULL);
  478.     if(SessionData.PgmControl & SSF_CONTROL_INVISIBLE)
  479.         WinSendDlgItemMsg(
  480.             nbPINotebookPage[PAGE_3].hwndPINBPage,
  481.             PIRB_INVISIBLE,             /* Program style: Invisible checkbox */
  482.             BM_SETCHECK,                /* Set it to pressed */
  483.             MPFROMSHORT(TRUE),
  484.             (MPARAM)NULL);
  485.     if(SessionData.PgmControl & SSF_CONTROL_NOAUTOCLOSE)
  486.         WinSendDlgItemMsg(
  487.             nbPINotebookPage[PAGE_3].hwndPINBPage,
  488.             PIRB_NOAUTOCLOSE,           /* Program style: NoAutoClose checkbox */
  489.             BM_SETCHECK,                /* Set it to pressed */
  490.             MPFROMSHORT(TRUE),
  491.             (MPARAM)NULL);
  492.     if(SessionData.FgBg & SSF_FGBG_BACK)
  493.         WinSendDlgItemMsg(
  494.             nbPINotebookPage[PAGE_3].hwndPINBPage,
  495.             PIRB_BACKGROUND,            /* Program style: Background checkbox */
  496.             BM_SETCHECK,                /* Set it to pressed */
  497.             MPFROMSHORT(TRUE),
  498.             (MPARAM)NULL);
  499. /*                                                                                      *\
  500.  * Now we preselect the radiobutton in the Program Size & Position group to the state   *
  501.  * indicated by the SessionData structure.                                              *
  502. \*                                                                                      */
  503.     if(SessionData.PgmControl & SSF_CONTROL_SETPOS)
  504.         {                               /* If requested select it for the first time */
  505.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_3].hwndPINBPage, PIRB_SIZEPOSITION, BM_SETCHECK,
  506.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  507.         WinSendMsg(hwndDlg, WM_SETUPSIZEPOSITION,
  508.             MPFROMSHORT(TRUE), MPFROMSHORT(TRUE));
  509.         }
  510.     else
  511.         WinSendMsg(hwndDlg, WM_SETUPSIZEPOSITION,
  512.             MPFROMSHORT(FALSE), MPFROMSHORT(TRUE));
  513.     }
  514.                                         /* Simulate the click to update the dialog's child windows */
  515.     WinSendMsg(nbPINotebookPage[PAGE_3].hwndPINBPage, WM_CONTROL,
  516.         MPFROM2SHORT(PIRB_SIZEPOSITION, BN_CLICKED), (MPARAM)NULL);
  517. /*                                                                                      *\
  518.  * Now we initialize the priority settings notebook page.                               *
  519. \*                                                                                      */
  520.      WinSendMsg(hwndDlg, WM_SETUPPROGRAMPRIORITY,
  521.         MPFROMSHORT(SessionData.PriorityClass), MPFROMSHORT(SessionData.PriorityDelta));
  522. /*                                                                                      *\
  523.  * Now we initialize the hotkey settings notebook page.                                 *
  524. \*                                                                                      */
  525.      WinSendMsg(hwndDlg, WM_SETUPHOTKEY, (MPARAM)NULL, (MPARAM)NULL);
  526. /*                                                                                      *\
  527.  * Subclass dialog window procedure to catch drag & drop messages of the dialog window, *
  528.  * which doesn't contain any child windows of it (entryfields, buttons, text fields).   *
  529. \*                                                                                      */
  530.                                         /* Subclass window procedure for drag & drop support
  531.                                            save the old procedure, because the subclassing procedure
  532.                                            must call the subclassed dialog procedure for all
  533.                                            messages it doesn't handle itself, i.e. all but drag & drop */
  534.     PI_ClassDialogProcedure=WinSubclassWindow(hwndDlg, PI_SubclassedDialogProcedure);
  535.     break;
  536.  
  537. /*                                                                                      *\
  538.  * Syntax: WM_SETUPPROGRAMTYPE, USHORT SessionType, NULL                                *
  539. \*                                                                                      */
  540. case WM_SETUPPROGRAMTYPE:
  541. /*                                                                                      *\
  542.  * Adjust the Program Type radiobuttons by selecting only the button corresponding to   *
  543.  * the SessionType.                                                                     *
  544. \*                                                                                      */
  545.     {                                   /* Radiobutton IDs sorted */
  546.     USHORT      usSessionTypeRBs[]={PIRB_SHELL, PIRB_OS2FULLSCREEN, PIRB_OS2WINDOW,
  547.                                     PIRB_PM, PIRB_DOSFULLSCREEN, PIRB_DOSWINDOW,
  548.                                     PIRB_WPSOBJECT};
  549.                                         /* Corresponding session type IDs sorted */
  550.     USHORT      usSessionTypeIDs[]={SSF_TYPE_DEFAULT, SSF_TYPE_FULLSCREEN, SSF_TYPE_WINDOWABLEVIO,
  551.                                     SSF_TYPE_PM, SSF_TYPE_VDM, SSF_TYPE_WINDOWEDVDM,
  552.                                     SSF_TYPE_WPSOBJECT};
  553.                                         /* Radiobutton IDs sorted */
  554.     USHORT      usWINOS2TypeRBs[]={PIRB_WINREAL, PIRB_WINSTANDARD, PIRB_WIN386ENHANCED};
  555.                                         /* Corresponding session type IDs sorted */
  556.     USHORT      usWINOS2TypeIDs[]={PROG_WINDOW_REAL, PROG_WINDOW_PROT, PROG_31_ENH};
  557.     USHORT      usSessionType=SHORT1FROMMP(mp1);
  558.     USHORT      usTemp;
  559.                                         /* Loop for all buttons and deselect all but the
  560.                                            one specified in usSessionType */
  561.     for(usTemp=0; usTemp<=(sizeof(usSessionTypeRBs)/sizeof(USHORT)); usTemp++)
  562.         if(usSessionTypeIDs[usTemp]==usSessionType)
  563.             {
  564.             WinSendDlgItemMsg(          /* Send message to one Program Type radiobutton,
  565.                                            this only updates the radiobutton but doesn't
  566.                                            create a WM_CONTROL message */
  567.                                         /* Handle of dialog window */
  568.                 nbPINotebookPage[PAGE_2].hwndPINBPage,
  569.                                         /* Program type radiobutton */
  570.                 usSessionTypeRBs[usTemp],
  571.                 BM_SETCHECK,            /* Set it to pressed */
  572.                 MPFROMSHORT(TRUE),
  573.                 (MPARAM)NULL);
  574.                                         /* Simulate the click to update the dialog's child windows */
  575.             WinSendMsg(nbPINotebookPage[PAGE_2].hwndPINBPage, WM_CONTROL,
  576.                 MPFROM2SHORT(usSessionTypeRBs[usTemp], BN_CLICKED), (MPARAM)NULL);
  577.             }
  578.     switch(usSessionType)
  579.     {                                   /* WIN-OS2 sessions must be treated similar */
  580.     case PROG_WINDOW_REAL:
  581.     case PROG_WINDOW_PROT:
  582.     case PROG_31_ENH:
  583.                                         /* Loop for all WIN-OS2 buttons and deselect all but the
  584.                                            one specified in usSessionType */
  585.         for(usTemp=0; usTemp<=(sizeof(usWINOS2TypeRBs)/sizeof(USHORT)); usTemp++)
  586.             if(usWINOS2TypeIDs[usTemp]==usSessionType)
  587.                 WinSendDlgItemMsg(nbPINotebookPage[PAGE_2].hwndPINBPage, usWINOS2TypeRBs[usTemp],
  588.                     BM_SETCHECK, MPFROMSHORT(TRUE), (MPARAM)NULL);
  589.                                         /* Check WIN-OS2 session type radiobutton */
  590.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_WINOS2, BM_SETCHECK,
  591.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  592.         WinSendMsg(nbPINotebookPage[PAGE_2].hwndPINBPage, WM_CONTROL,
  593.             MPFROM2SHORT(PIRB_WINOS2, BN_CLICKED), (MPARAM)NULL);
  594.         break;
  595.  
  596.     default:
  597.                                         /* Check WIN standard session radiobutton, because at
  598.                                            least one should be checked, if no WIN-OS2 session
  599.                                            type is selected */
  600.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_WINSTANDARD, BM_SETCHECK,
  601.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  602.         break;
  603.     }
  604.                                         /* Hide DOS Settings window until the application
  605.                                            type is DOS Window or DOS Fullscreen */
  606.     if(usSessionType==SSF_TYPE_WPSOBJECT)
  607.                                         /* Only default Style is allowed */
  608.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_3].hwndPINBPage, PIRB_DEFAULTSTYLE, BM_SETCHECK,
  609.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  610.     }
  611.     break;
  612.  
  613. /*                                                                                      *\
  614.  * Syntax: WM_SETUPSIZEPOSITION, (BOOL bWriteable), (BOOL bInsert)                      *
  615. \*                                                                                      */
  616. case WM_SETUPSIZEPOSITION:
  617. /*                                                                                      *\
  618.  * The 4 entryfields for the Size&Position are a bit more complicated to handle.        *
  619.  * First we set the entryfields to a size of 4 and the default values are read from the *
  620.  * SessionData structure. Only if Size&Position is selected, this 4 entryfields are not *
  621.  * readonly. Flag bWriteable is true if Size&Position is selected, Flag bInsert is true *
  622.  * if we write the values the first time.                                               *
  623. \*                                                                                      */
  624.     {
  625.     USHORT      usSizePositionEFs[]={PIEF_X, PIEF_Y, PIEF_XSIZE, PIEF_YSIZE};
  626.     BOOL        bWriteable=SHORT1FROMMP(mp1);
  627.     BOOL        bInsert=SHORT1FROMMP(mp2);
  628.     USHORT      usTemp;
  629.     SHORT       *psSizePosition;
  630.     UCHAR       ucBuffer[6];            /* Prefix, 4 numbers, \0 */
  631.  
  632.                                         /* Get first Size & Position value */
  633.     psSizePosition=&SessionData.InitXPos;
  634.                                         /* Loop for all entryfields and enable and insert
  635.                                            values into them */
  636.     for(usTemp=0; usTemp<=(sizeof(usSizePositionEFs)/sizeof(USHORT));
  637.         usTemp++, psSizePosition++)
  638.         {
  639.         if(bWriteable==TRUE)            /* If writeable, enable them */
  640.             WinSendDlgItemMsg(          /* Send message to entryfield */
  641.                 nbPINotebookPage[PAGE_3].hwndPINBPage,
  642.                                         /* Program size & position entryfield */
  643.                 usSizePositionEFs[usTemp],
  644.                 EM_SETREADONLY,         /* Set to enable read/write */
  645.                 MPFROMSHORT(FALSE),
  646.                 (MPARAM)NULL);
  647.         else
  648.             WinSendDlgItemMsg(          /* Send message to entryfield */
  649.                 nbPINotebookPage[PAGE_3].hwndPINBPage,
  650.                                         /* Program size & position entryfield */
  651.                 usSizePositionEFs[usTemp],
  652.                 EM_SETREADONLY,         /* Set to enable readonly */
  653.                 MPFROMSHORT(TRUE),
  654.                 (MPARAM)NULL);
  655.         if(bInsert==TRUE)               /* If initializing, insert them */
  656.             {
  657.             WinSendDlgItemMsg(          /* Send message to dialog window */
  658.                                         /* Handle of dialog window */
  659.                 nbPINotebookPage[PAGE_3].hwndPINBPage,
  660.                                         /* Program size: X entryfield */
  661.                 usSizePositionEFs[usTemp],
  662.                 EM_SETTEXTLIMIT,        /* Set text limit to 5 */
  663.                 MPFROMSHORT(5),
  664.                 (MPARAM)NULL);
  665.             WinSetDlgItemText(          /* Set a text string in a dialog item */
  666.                 nbPINotebookPage[PAGE_3].hwndPINBPage,
  667.                 usSizePositionEFs[usTemp],
  668.                 (CHAR *)_itoa(*psSizePosition, ucBuffer, 10));
  669.             }
  670.         }
  671.     }
  672.     break;
  673.  
  674. /*                                                                                      *\
  675.  * Syntax: WM_SETUPHOTKEY, NULL, NULL                                                   *
  676. \*                                                                                      */
  677. case WM_SETUPHOTKEY:
  678. /*                                                                                      *\
  679.  * Load Program Title into entryfield, fill the combobox and fill the MLE containing    *
  680.  * the current window list.                                                             *
  681. \*                                                                                      */
  682.     {
  683.     ULONG       ulTemp1, ulTemp2;
  684.     PSWBLOCK    pSwBlock;               /* Pointer to window list */
  685.                                         /* Used to add \n to switchlist entries */
  686.     UCHAR       ucSwName[MAXNAMEL+1];
  687.  
  688.                                         /* Set Window Title entryfield */
  689.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, PIEF_SESSIONTITLE,
  690.         EM_SETTEXTLIMIT, MPFROMSHORT(MAXNAMEL), (MPARAM)NULL);
  691.     WinSetDlgItemText(nbPINotebookPage[PAGE_4].hwndPINBPage, PIEF_SESSIONTITLE, SessionData.WindowTitle);
  692.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, PICBX_HOTKEY,
  693.         EM_SETTEXTLIMIT, MPFROMSHORT(sizeof(" ")), (MPARAM)NULL);
  694.                                         /* Set SWP control radiobuttons */
  695.     if(SessionData.SwpFlag & SWP_MAXIMIZE)
  696.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, PIRB_WSMAXIMIZED, BM_SETCHECK,
  697.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  698.     else if(SessionData.SwpFlag & SWP_RESTORE)
  699.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, PIRB_WSRESTORE, BM_SETCHECK,
  700.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  701.     else
  702.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, PIRB_NONE, BM_SETCHECK,
  703.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  704.     if(SessionData.SwpFlag & SWP_NOMOVE)
  705.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, PICB_DONTMOVE, BM_SETCHECK,
  706.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  707.     if(SessionData.KeyData.usCh!=0)     /* Check if a hotkey is defined */
  708.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, PICB_HOTKEYENABLED, BM_SETCHECK,
  709.             MPFROMSHORT(TRUE), (MPARAM)NULL);
  710.                                         /* Simulate the click to update the dialog's child windows */
  711.     WinSendMsg(nbPINotebookPage[PAGE_2].hwndPINBPage, WM_CONTROL,
  712.         MPFROM2SHORT(PICB_HOTKEYENABLED, BN_CLICKED), (MPARAM)NULL);
  713.                                         /* Simulate the click to update the PIRB_CTRL or
  714.                                            PIRB_ALT radiobutton */
  715.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, (SessionData.KeyData.usFlags==KC_CTRL) ? PIRB_CTRL : PIRB_ALT,
  716.         BM_SETCHECK, MPFROMSHORT(TRUE), (MPARAM)NULL);
  717.                                         /* This message invalidates SessionData.KeyData !!! */
  718.     WinSendMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, WM_CONTROL,
  719.         MPFROM2SHORT((SessionData.KeyData.usFlags==KC_CTRL) ? PIRB_CTRL : PIRB_ALT, BN_CLICKED), (MPARAM)NULL);
  720.                                         /* Query the number of entries in window list */
  721.     ulTemp1=WinQuerySwitchList(hab, NULL, 0);
  722.                                         /* Allocate space for window list */
  723.     pSwBlock=(PSWBLOCK)malloc(ulTemp1=(ulTemp1*sizeof(SWENTRY)+sizeof(HSWITCH)));
  724.                                         /* Load window list into LB */
  725.     ulTemp1=WinQuerySwitchList(hab, pSwBlock, ulTemp1);
  726.     for(ulTemp2=0; ulTemp2<=ulTemp1; ulTemp2++)
  727.         {
  728.         if(pSwBlock->aswentry[ulTemp2].swctl.fbJump==SWL_JUMPABLE)
  729.             {
  730.             strcpy(ucSwName, pSwBlock->aswentry[ulTemp2].swctl.szSwtitle);
  731.             WinSendDlgItemMsg(
  732.                 nbPINotebookPage[PAGE_4].hwndPINBPage, PILB_WINDOWLIST,
  733.                 LM_INSERTITEM, MPFROMSHORT(LIT_END), MPFROMP(ucSwName));
  734.             }
  735.         }
  736.     free(pSwBlock);                     /* Free allocated space for window list */
  737.     }
  738.     break;
  739.  
  740. /*                                                                                      *\
  741.  * Syntax: WM_SETUPPROGRAMPRIORITY, (USHORT PriorityClass), (SHORT PriorityDelta)       *                                           *
  742. \*                                                                                      */
  743. case WM_SETUPPROGRAMPRIORITY:
  744. /*                                                                                      *\
  745.  * To enable all Priorities to be selected, the checkbox PICB_CHILDPROCESS must be      *
  746.  * checked and is either checked by the user or by the Priority not equal to the        *
  747.  * default selection of PRTYC_NOCHANGE and 0.                                           *
  748. \*                                                                                      */
  749.     {
  750.     USHORT      usPriorityClassRBs[]={PIRB_NOCHANGE, PIRB_IDLETIME, PIRB_REGULAR,
  751.                                       PIRB_TIMECRITICAL, PIRB_FOREGROUNDSERVER};
  752.     USHORT      usPriorityClass=SHORT1FROMMP(mp1);
  753.     UCHAR       ucBuffer[4];
  754.  
  755.     sPriorityDelta=SHORT1FROMMP(mp2);
  756.                                         /* Check priority class radiobutton by simulation a 
  757.                                            radiobutton click */
  758.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndPINBPage, usPriorityClassRBs[usPriorityClass],
  759.         BM_SETCHECK, MPFROMSHORT(TRUE), (MPARAM)NULL);
  760.     WinSendMsg(nbPINotebookPage[PAGE_5].hwndPINBPage, WM_CONTROL,
  761.         MPFROM2SHORT(usPriorityClass, BN_CLICKED), (MPARAM)NULL);
  762.                                         /* Set priority delta entryfield and scrollbar */
  763.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndPINBPage, PIEF_PRIORITYDELTA,
  764.         EM_SETTEXTLIMIT, MPFROMSHORT(3), (MPARAM)NULL);
  765.     WinSetDlgItemText(nbPINotebookPage[PAGE_5].hwndPINBPage, PIEF_PRIORITYDELTA,
  766.         (CHAR *)_itoa(sPriorityDelta, ucBuffer, 10));
  767.                                         /* Set scollbar size and position. Caution
  768.                                            a scrollbar is 0 based */
  769.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndPINBPage, PIHSB_PRIORITYDELTA,
  770.         SBM_SETTHUMBSIZE, MPFROM2SHORT(1, PRTYD_MAXIMUM), (MPARAM)NULL);
  771.     WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndPINBPage, PIHSB_PRIORITYDELTA,
  772.         SBM_SETSCROLLBAR, MPFROMSHORT(sPriorityDelta),
  773.         MPFROM2SHORT(0, PRTYD_MAXIMUM));
  774.     }
  775.     break;
  776.  
  777. case WM_HSCROLL:                        /* Messages generated by horizontal scrollbars */
  778. /*                                                                                      *\
  779.  * This message is generated when a horizontal scrollbar is manipulated. See if it is   *
  780.  * our scrollbar PIHSB_PRIORITYDELTA and process.                                       *
  781. \*                                                                                      */
  782.     if(SHORT1FROMMP(mp1)==PIHSB_PRIORITYDELTA)
  783.         {
  784.         UCHAR       ucBuffer[4];
  785.         SHORT       sSliderPosition=SHORT1FROMMP(mp2);;
  786.  
  787.         switch(SHORT2FROMMP(mp2))
  788.         {                               /* All messages contain the new slider position,
  789.                                            so just use this value to change the priority
  790.                                            delta entryfield value */
  791.         case SB_LINELEFT:
  792.             sPriorityDelta--;
  793.             break;
  794.  
  795.         case SB_PAGELEFT:
  796.             sPriorityDelta-=10;
  797.             break;
  798.  
  799.         case SB_LINERIGHT:
  800.             sPriorityDelta++;
  801.             break;
  802.  
  803.         case SB_PAGERIGHT:
  804.             sPriorityDelta+=10;
  805.             break;
  806.  
  807.         case SB_SLIDERTRACK:
  808.         case SB_SLIDERPOSITION:
  809.             sPriorityDelta=sSliderPosition;
  810.             break;
  811.         }
  812.         if(sPriorityDelta<PRTYC_NOCHANGE) sPriorityDelta=PRTYC_NOCHANGE;
  813.         if(sPriorityDelta>PRTYD_MAXIMUM) sPriorityDelta=PRTYD_MAXIMUM;
  814.         WinSetDlgItemText(nbPINotebookPage[PAGE_5].hwndPINBPage, PIEF_PRIORITYDELTA,
  815.             (CHAR *)_itoa(sPriorityDelta, ucBuffer, 10));
  816.         WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndPINBPage, PIHSB_PRIORITYDELTA,
  817.             SBM_SETPOS, MPFROMSHORT(sPriorityDelta), (MPARAM)NULL);
  818.         }
  819.     break;
  820.  
  821. case WM_CONTROL:                        /* Test for autoradio buttons pressed */
  822. /*                                                                                      *\
  823.  * The Size & Position radiobutton must be checked every time it is selected, because   *
  824.  * only if it is selected, the user may have write access to X, Y, Size X and Size Y    *
  825.  * entryfields, otherwise they are read only. The DOS Setting MLE is only visible if a  *
  826.  * DOS window or fullscreen application type is selected.                               *
  827. \*                                                                                      */
  828.     {                                   /* Child windows that change with the
  829.                                            PIRB_WPSOBJECT radiobutton */
  830.     USHORT      usChild2WPSObject[]={PIRB_MAXIMIZED, PIRB_MINIMIZED, PIRB_SIZEPOSITION,
  831.                                      PIRB_INVISIBLE, PIRB_NOAUTOCLOSE, PIRB_BACKGROUND,
  832.                                      PIEF_X, PIEF_Y, PIEF_XSIZE, PIEF_YSIZE};
  833.                                         /* Disable the following if Size & Position is disabled */
  834.     USHORT      usChild2SizeEnable[]={PIEF_X, PIEF_Y, PIEF_XSIZE, PIEF_YSIZE};
  835.                                         /* Hide the following for WPS Objects */
  836.     USHORT      usChild2WPSObjectHide[]={PIEF_DIRECTORY, PIEF_PARAMETERS};
  837.                                         /* Child window that changes with a DOS radiobutton */
  838.     USHORT      usChild2DOS[]={PIMLE_DOSSETTINGS};
  839.     USHORT      usChild2DOSP5[]={PIRB_IDLETIME, PIRB_REGULAR, PIRB_TIMECRITICAL, PIRB_FOREGROUNDSERVER,
  840.                                  PIEF_PRIORITYDELTA, PIHSB_PRIORITYDELTA};
  841.                                         /* Child windows that change with a WIN-OS2 radiobutton */
  842.     USHORT      usChild2WINOS2[]={PIRB_WINREAL, PIRB_WINSTANDARD, PIRB_WIN386ENHANCED/*,
  843.                                   PICB_WINCOMMON*/};
  844.                                         /* Child windows that change witch Hotkey enable checkbox */
  845.     USHORT      usChild2HotKey[]={PIRB_NONE, PIRB_WSMAXIMIZED, PIRB_WSRESTORE, PIRB_CTRL,
  846.                                   PIRB_ALT, PICBX_HOTKEY};
  847.  
  848.     if(SHORT2FROMMP(mp1)==BN_CLICKED)   /* Was autoradio button clicked ? */
  849.         switch(SHORT1FROMMP(mp1))
  850.         {
  851.         case PIRB_SIZEPOSITION:         /* Program type: User defined size & position */
  852.             if((BOOL)WinSendDlgItemMsg( /* Send message to Size & Position radiobutton */
  853.                                         /* Handle of dialog window */
  854.                 nbPINotebookPage[PAGE_3].hwndPINBPage,
  855.                 PIRB_SIZEPOSITION,      /* Program size: Size & Position radiobutton */
  856.                 BM_QUERYCHECK,          /* Query the state */
  857.                 (MPARAM)NULL,
  858.                 (MPARAM)NULL)==TRUE)
  859.                 {
  860.                 WinSendMsg(hwndDlg, WM_SETUPSIZEPOSITION,
  861.                     MPFROMSHORT(TRUE), MPFROMSHORT(FALSE));
  862.                 DisableDialogItem(nbPINotebookPage[PAGE_3].hwndPINBPage, usChild2SizeEnable,
  863.                     sizeof(usChild2SizeEnable)/sizeof(USHORT), WS_VISIBLE);
  864.                 }
  865.             else
  866.                 {
  867.                 WinSendMsg(hwndDlg, WM_SETUPSIZEPOSITION,
  868.                     MPFROMSHORT(FALSE), MPFROMSHORT(FALSE));
  869.                                         /* Enable and show Size & Position child windows */
  870.                                         /* Disable and show Size & Position child windows */
  871.                 DisableDialogItem(nbPINotebookPage[PAGE_3].hwndPINBPage, usChild2SizeEnable,
  872.                     sizeof(usChild2SizeEnable)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  873.                 }
  874.             break;
  875.  
  876.         case PICB_HOTKEYENABLED:        /* Enable or disable and show Hotkey controls depending
  877.                                            on Hotkey Enable checkbox */
  878.             if((BOOL)WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage,
  879.                 PICB_HOTKEYENABLED, BM_QUERYCHECK, (MPARAM)NULL, (MPARAM)NULL)==TRUE)
  880.                 {
  881.                 DisableDialogItem(nbPINotebookPage[PAGE_4].hwndPINBPage, usChild2HotKey,
  882.                     sizeof(usChild2HotKey)/sizeof(USHORT), WS_VISIBLE);
  883.                 }
  884.             else
  885.                 {
  886.                 DisableDialogItem(nbPINotebookPage[PAGE_4].hwndPINBPage, usChild2HotKey,
  887.                     sizeof(usChild2HotKey)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  888.                 }
  889.             break;
  890.  
  891.         case PIRB_CTRL:
  892.         case PIRB_ALT:                  /* Set hotkey MLE corresponding to radiobuttons */
  893.             {
  894.             KEYDATA     *pKeyData;
  895.             UCHAR       ucBuffer[]="0"; /* String to be inserted into combobox */
  896.             ULONG       ulTemp1;
  897.             BOOL        bFirst=TRUE;    /* False if first key was inserted */
  898.  
  899.             pKeyData=KeyData;           /* Point to Hotkey control structure */
  900.                                         /* If a key is defined set it into entryfield of
  901.                                            combobox. Clear it afterwards that user selections
  902.                                            to the PIRB_CTRL or PIRB_ALT insert the first free
  903.                                            available key */
  904.             if(SessionData.KeyData.usCh!=0)
  905.                 {
  906.                 ucBuffer[0]=(UCHAR)SessionData.KeyData.usCh;
  907.                 WinSetDlgItemText(nbPINotebookPage[PAGE_4].hwndPINBPage, PICBX_HOTKEY, ucBuffer);
  908.                 bFirst=FALSE;
  909.                 }
  910.             else bFirst=TRUE;
  911.                                         /* Delete current entries in hotkey combobox */
  912.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, PICBX_HOTKEY,
  913.                 LM_DELETEALL, (MPARAM)NULL, (MPARAM)NULL);
  914.                                         /* Loop for all keys and set unused into combobox */
  915.             for(ulTemp1=0; ulTemp1<(sizeof(KeyData)/sizeof(KEYDATA)); pKeyData++, ulTemp1++)
  916.                 {
  917.                 ucBuffer[0]=(UCHAR)pKeyData->usCh;
  918.                                         /* Clear current key because it may not selected again */
  919.                 if((pKeyData->usCh==SessionData.KeyData.usCh) &&
  920.                     ((SHORT1FROMMP(mp1)==PIRB_CTRL ? KC_CTRL : KC_ALT)==pKeyData->usFlags))
  921.                     {
  922.                     SessionData.KeyData.usCh=0;
  923.                     pKeyData->bUsed=FALSE;
  924.                     pKeyData->pMenuData=NULL;
  925.                     }
  926.                                         /* Load unused key of current type into combobox */
  927.                 if((pKeyData->bUsed==FALSE) &&
  928.                     ((SHORT1FROMMP(mp1)==PIRB_CTRL ? KC_CTRL : KC_ALT)==pKeyData->usFlags))
  929.                     {
  930.                     if(bFirst==TRUE)
  931.                         {               /* The first valid hotkey is loaded into entryfield part
  932.                                            of combobox */
  933.                         WinSetDlgItemText(nbPINotebookPage[PAGE_4].hwndPINBPage, PICBX_HOTKEY, ucBuffer);
  934.                         bFirst=FALSE;
  935.                         }
  936.                     WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, PICBX_HOTKEY,
  937.                         LM_INSERTITEM, MPFROMSHORT(LIT_END), MPFROMP(ucBuffer));
  938.                     }
  939.                 }
  940.             }
  941.             break;
  942.  
  943.         case PIRB_DOSFULLSCREEN:
  944.         case PIRB_DOSWINDOW:
  945.                                         /* Enable and show WPSObject child windows */
  946.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndPINBPage, usChild2WPSObjectHide,
  947.                 sizeof(usChild2WPSObjectHide)/sizeof(USHORT), WS_VISIBLE);
  948.                                         /* Enable and show DOS child windows */
  949.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndPINBPage, usChild2DOS,
  950.                 sizeof(usChild2DOS)/sizeof(USHORT), WS_VISIBLE);
  951.                                         /* Set default priority class radiobutton by simulation a
  952.                                            radiobutton click */
  953.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndPINBPage, PIRB_NOCHANGE,
  954.                 BM_SETCHECK, MPFROMSHORT(TRUE), (MPARAM)NULL);
  955.             WinSendMsg(nbPINotebookPage[PAGE_5].hwndPINBPage, WM_CONTROL,
  956.                 MPFROM2SHORT(PIRB_NOCHANGE, BN_CLICKED), (MPARAM)NULL);
  957.                                         /* Set default priority delta entryfield and scrollbar */
  958.             WinSetDlgItemText(nbPINotebookPage[PAGE_5].hwndPINBPage, PIEF_PRIORITYDELTA, "0");
  959.                                         /* Set default scollbar position */
  960.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndPINBPage, PIHSB_PRIORITYDELTA,
  961.                 SBM_SETPOS, MPFROMSHORT(0), (MPARAM)NULL);
  962.                                         /* Now disable non-default priority settings */
  963.             DisableDialogItem(nbPINotebookPage[PAGE_5].hwndPINBPage, usChild2DOSP5,
  964.                 sizeof(usChild2DOSP5)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  965.                                         /* Enable and show WPSObject child windows */
  966.             DisableDialogItem(nbPINotebookPage[PAGE_3].hwndPINBPage, usChild2WPSObject,
  967.                 sizeof(usChild2WPSObject)/sizeof(USHORT), WS_VISIBLE);
  968.                                         /* Disable and show WIN-OS2 child windows */
  969.             DisableDialogItem(nbPINotebookPage[PAGE_2].hwndPINBPage, usChild2WINOS2,
  970.                 sizeof(usChild2WINOS2)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  971.             break;
  972.  
  973.         case PIRB_SHELL:
  974.         case PIRB_OS2FULLSCREEN:
  975.         case PIRB_OS2WINDOW:
  976.         case PIRB_PM:
  977.                                         /* Enable and hide DOS child windows */
  978.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndPINBPage, usChild2DOS,
  979.                 sizeof(usChild2DOS)/sizeof(USHORT), 0);
  980.                                         /* Now enable priority settings */
  981.             DisableDialogItem(nbPINotebookPage[PAGE_5].hwndPINBPage, usChild2DOSP5,
  982.                 sizeof(usChild2DOSP5)/sizeof(USHORT), WS_VISIBLE);
  983.                                         /* Enable and show WPSObject child windows */
  984.             DisableDialogItem(nbPINotebookPage[PAGE_3].hwndPINBPage, usChild2WPSObject,
  985.                 sizeof(usChild2WPSObject)/sizeof(USHORT), WS_VISIBLE);
  986.                                         /* Enable and show WPSObject child windows */
  987.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndPINBPage, usChild2WPSObjectHide,
  988.                 sizeof(usChild2WPSObjectHide)/sizeof(USHORT), WS_VISIBLE);
  989.                                         /* Disable and show WIN-OS2 child windows */
  990.             DisableDialogItem(nbPINotebookPage[PAGE_2].hwndPINBPage, usChild2WINOS2,
  991.                 sizeof(usChild2WINOS2)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  992.             break;
  993.         
  994.         case PIRB_WPSOBJECT:
  995.                                         /* Disable and show WPSObject child windows */
  996.             DisableDialogItem(nbPINotebookPage[PAGE_3].hwndPINBPage, usChild2WPSObject,
  997.                 sizeof(usChild2WPSObject)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  998.                                         /* Enable and hide DOS child windows */
  999.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndPINBPage, usChild2DOS,
  1000.                 sizeof(usChild2DOS)/sizeof(USHORT), 0);
  1001.                                         /* Now enable priority settings */
  1002.             DisableDialogItem(nbPINotebookPage[PAGE_5].hwndPINBPage, usChild2DOSP5,
  1003.                 sizeof(usChild2DOSP5)/sizeof(USHORT), WS_VISIBLE);
  1004.                                         /* Hide but enable WPSObject child windows */
  1005.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndPINBPage, usChild2WPSObjectHide,
  1006.                 sizeof(usChild2WPSObjectHide)/sizeof(USHORT), 0);
  1007.                                         /* Disable and show WIN-OS2 child windows */
  1008.             DisableDialogItem(nbPINotebookPage[PAGE_2].hwndPINBPage, usChild2WINOS2,
  1009.                 sizeof(usChild2WINOS2)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  1010.                                         /* Only default Style is allowed */
  1011.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_3].hwndPINBPage, PIRB_DEFAULTSTYLE, BM_SETCHECK,
  1012.                 MPFROMSHORT(TRUE), (MPARAM)NULL);
  1013.                                         /* Size and Position is not allowed */
  1014.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_3].hwndPINBPage, PIRB_SIZEPOSITION, BM_SETCHECK,
  1015.                 MPFROMSHORT(FALSE), (MPARAM)NULL);
  1016.                                         /* Load empty text in not required fields */
  1017.             WinSetDlgItemText(nbPINotebookPage[PAGE_1].hwndPINBPage, PIEF_DIRECTORY, "");
  1018.             WinSetDlgItemText(nbPINotebookPage[PAGE_1].hwndPINBPage, PIEF_PARAMETERS, "");
  1019.             break;
  1020.  
  1021.         case PIRB_WINOS2:
  1022.                                         /* Enable and show WPSObject child windows, because
  1023.                                            a WIN-OS2 session is a specail DOS session */
  1024.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndPINBPage, usChild2WPSObjectHide,
  1025.                 sizeof(usChild2WPSObjectHide)/sizeof(USHORT), WS_VISIBLE);
  1026.                                         /* Enable and show DOS child windows, hide priority */
  1027.             DisableDialogItem(nbPINotebookPage[PAGE_1].hwndPINBPage, usChild2DOS,
  1028.                 sizeof(usChild2DOS)/sizeof(USHORT), WS_VISIBLE);
  1029.                                         /* Set default priority class radiobutton by simulation a
  1030.                                            radiobutton click */
  1031.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndPINBPage, PIRB_NOCHANGE,
  1032.                 BM_SETCHECK, MPFROMSHORT(TRUE), (MPARAM)NULL);
  1033.             WinSendMsg(nbPINotebookPage[PAGE_5].hwndPINBPage, WM_CONTROL,
  1034.                 MPFROM2SHORT(PIRB_NOCHANGE, BN_CLICKED), (MPARAM)NULL);
  1035.                                         /* Set default priority delta entryfield and scrollbar */
  1036.             WinSetDlgItemText(nbPINotebookPage[PAGE_5].hwndPINBPage, PIEF_PRIORITYDELTA, "0");
  1037.                                         /* Set default scollbar position */
  1038.             WinSendDlgItemMsg(nbPINotebookPage[PAGE_5].hwndPINBPage, PIHSB_PRIORITYDELTA,
  1039.                 SBM_SETPOS, MPFROMSHORT(0), (MPARAM)NULL);
  1040.                                         /* Now disable non-default priority settings */
  1041.             DisableDialogItem(nbPINotebookPage[PAGE_5].hwndPINBPage, usChild2DOSP5,
  1042.                 sizeof(usChild2DOSP5)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  1043.                                         /* Enable and show WPSObject child windows */
  1044.             DisableDialogItem(nbPINotebookPage[PAGE_3].hwndPINBPage, usChild2WPSObject,
  1045.                 sizeof(usChild2WPSObject)/sizeof(USHORT), WS_VISIBLE);
  1046.                                         /* Enable and show WIN-OS2 child windows */
  1047.             DisableDialogItem(nbPINotebookPage[PAGE_2].hwndPINBPage, usChild2WINOS2,
  1048.                 sizeof(usChild2WINOS2)/sizeof(USHORT), WS_VISIBLE);
  1049.             break;
  1050.         }
  1051.     if(SHORT1FROMMP(mp1)==PILB_WINDOWLIST)
  1052.         switch(SHORT2FROMMP(mp1))       /* Events of Window List listbox */
  1053.         {
  1054.         case LN_ENTER:                  /* When selected, copy selected item into session title entryfield */
  1055.             {
  1056.             UCHAR   ucTemp[MAXNAMEL];
  1057.             USHORT  usSelection;
  1058.  
  1059.             usSelection=(USHORT)WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, PILB_WINDOWLIST,
  1060.                 LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), (MPARAM)NULL);
  1061.                                         /* Copy selected item */
  1062.             if(usSelection!=(USHORT)LIT_NONE)
  1063.                 {
  1064.                 WinSendDlgItemMsg(nbPINotebookPage[PAGE_4].hwndPINBPage, PILB_WINDOWLIST,
  1065.                     LM_QUERYITEMTEXT, MPFROM2SHORT(usSelection, MAXNAMEL), MPFROMP(ucTemp));
  1066.                 WinSetDlgItemText(nbPINotebookPage[PAGE_4].hwndPINBPage, PIEF_SESSIONTITLE, ucTemp);
  1067.                 }
  1068.             break;
  1069.             }
  1070.         }
  1071.     }
  1072.     break;
  1073.  
  1074. case WM_COMMAND:                        /* Button pressed */
  1075.     switch(SHORT1FROMMP(mp1))
  1076.     {
  1077.     case PIPB_WINFILEDLG:               /* Locate file by standard file dialog */
  1078. /*                                                                                      *\
  1079.  * The user selected the File Find pushbutton to get the standard file dialog to find   *
  1080.  * the program he wants to install.                                                     *
  1081. \*                                                                                      */
  1082.         {
  1083.         FILEDLG fdFileDlg;              /* Standard file dialog control */
  1084.         HWND    hwndFileDlg;            /* Handle of standard file dialog */
  1085.  
  1086.                                         /* Clear out structure */
  1087.         memset(&fdFileDlg, 0, sizeof(FILEDLG));
  1088.                                         /* Structure size */
  1089.         fdFileDlg.cbSize=sizeof(FILEDLG);
  1090.                                         /* FDS_* flags */
  1091.         fdFileDlg.fl=FDS_CENTER | FDS_OPEN_DIALOG | FDS_PRELOAD_VOLINFO;
  1092.                                         /* Dialog title string */
  1093.         fdFileDlg.pszTitle="PC/2 File Search";
  1094.                                         /* Initial path, filename or file filter */
  1095.         strcpy(fdFileDlg.szFullFile, "C:\\*");
  1096.                                         /* Open the standard file dialog ...*/
  1097.         hwndFileDlg=WinFileDlg(HWND_DESKTOP, hwndDlg, &fdFileDlg);
  1098.         if(hwndFileDlg && (fdFileDlg.lReturn==DID_OK))
  1099.                                         /* Load the values of the standard file dialog to
  1100.                                            the corresponding entryfield in the Program
  1101.                                            installation dialog. It is a file not an object. */
  1102.             InstallFilename2Dialog(hwndDlg, fdFileDlg.szFullFile, FALSE);
  1103.         }
  1104.         break;
  1105.  
  1106.     default:
  1107.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1108.     }
  1109.     break;
  1110.  
  1111. default:                                /* Default window procedure must be called */
  1112.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1113. }
  1114. return((MRESULT)FALSE);                 /* We have handled the message */
  1115. }
  1116.  
  1117. /*--------------------------------------------------------------------------------------*\
  1118.  * This dialog procedure handles the PC/2 - Program Installation dialog.                *
  1119.  * Req:                                                                                 *
  1120.  *      StartSession .. a structure of type SESSIONDATA where the information entered   *
  1121.  *                      in the dialog is entered. If DID_OK is pressed this structure   *
  1122.  *                      is used to start the session and set its priority.              *
  1123. \*--------------------------------------------------------------------------------------*/
  1124. MRESULT  EXPENTRY PI_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  1125. {
  1126. static HWND          hwndNB;            /* Program Installation dialog notebook window handle */
  1127.  
  1128. switch(msg)
  1129. {
  1130. case WM_INITDLG:
  1131.     {
  1132.     HPS         hps;                    /* Used to query font metrics for tab size */
  1133.     FONTMETRICS fmFontMetrics;
  1134.     POINTL      aptlTabText[TXTBOX_COUNT];
  1135.     USHORT      usTabTextLength=50;
  1136.     SWP         swp;
  1137.     ULONG       ulPage, ulPageID;
  1138.  
  1139.  
  1140.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  1141.                                         /* Get window handle of notebook */
  1142.     hwndNB=WinWindowFromID(hwndDlg, PINB_NOTEBOOK);
  1143.     hps=WinGetPS(hwndNB);               /* Get presentation space to query fontmetrics */
  1144.     memset(&fmFontMetrics, 0, sizeof(FONTMETRICS));
  1145.     if(GpiQueryFontMetrics(hps, sizeof(FONTMETRICS), &fmFontMetrics))
  1146.         fmFontMetrics.lMaxBaselineExt<<=1;
  1147.     else
  1148.         fmFontMetrics.lMaxBaselineExt=30;
  1149.                                         /* Load and associate all dialogs of the Program
  1150.                                            Installation dialog to notebook pages */
  1151.     for(ulPage=0; nbPINotebookPage[ulPage].pDialogWndProc!=NULL; ulPage++)
  1152.         {
  1153.                                         /* Load a dialog into a page */
  1154.         if(!(nbPINotebookPage[ulPage].hwndPINBPage=WinLoadDlg(
  1155.             hwndDlg,                    /* Parent window */
  1156.             hwndDlg,                    /* Owner window */
  1157.                                         /* Window procedure */
  1158.             nbPINotebookPage[ulPage].pDialogWndProc,
  1159.             NULLHANDLE,                 /* Resource idendity */
  1160.                                         /* Dialog idendity */
  1161.             nbPINotebookPage[ulPage].ulIDDialogPage,
  1162.             NULL)))                     /* Application defined data area */
  1163.                                         /* On error suggest exiting */
  1164.         USR_ERR("Can't load dialog resources - suggest exiting...", hwndFrame, hwndClient);
  1165.                                         /* Query length of largest tab text */
  1166.         if(GpiQueryTextBox(hps, strlen(nbPINotebookPage[ulPage].pszTab),
  1167.             nbPINotebookPage[ulPage].pszTab, TXTBOX_COUNT, aptlTabText))
  1168.             if(usTabTextLength<aptlTabText[TXTBOX_CONCAT].x)
  1169.                 usTabTextLength=aptlTabText[TXTBOX_CONCAT].x;
  1170.         ulPageID=(ULONG)WinSendMsg(     /* Insert a page into the notebook */
  1171.             hwndNB,
  1172.             BKM_INSERTPAGE,
  1173.             (MPARAM)NULL,               /* Page ID, ignored if BKA_FIRST or BKA_LAST
  1174.                                            specified */
  1175.                                         /* Style and order attribute */
  1176.             MPFROM2SHORT(BKA_MAJOR | BKA_STATUSTEXTON | BKA_AUTOPAGESIZE, BKA_LAST));
  1177.         nbPINotebookPage[ulPage].ulIDPage=ulPageID;
  1178.                                         /* Set text into the status line */
  1179.         WinSendMsg(hwndNB,
  1180.             BKM_SETSTATUSLINETEXT,
  1181.             MPFROMP(ulPageID),
  1182.             MPFROMP(nbPINotebookPage[ulPage].pszStatusLine));
  1183.                                         /* Set text into tab */
  1184.         WinSendMsg(hwndNB,
  1185.             BKM_SETTABTEXT,
  1186.             MPFROMP(ulPageID),
  1187.             MPFROMP(nbPINotebookPage[ulPage].pszTab));
  1188.                                         /* Associate page with dialog */
  1189.         WinSendMsg(hwndNB,
  1190.             BKM_SETPAGEWINDOWHWND,
  1191.             MPFROMP(ulPageID),
  1192.             MPFROMLONG(nbPINotebookPage[ulPage].hwndPINBPage));
  1193.         }
  1194.     WinReleasePS(hps);
  1195.     WinSendMsg(hwndNB,                  /* Set background to dialog box background */
  1196.         BKM_SETNOTEBOOKCOLORS,
  1197.         MPFROMLONG(SYSCLR_FIELDBACKGROUND),
  1198.         MPFROMSHORT(BKA_BACKGROUNDPAGECOLORINDEX));
  1199.     WinSendMsg(hwndNB,                  /* Set tab dimension */
  1200.         BKM_SETDIMENSIONS,
  1201.         MPFROM2SHORT(usTabTextLength+5, (SHORT)((float)fmFontMetrics.lMaxBaselineExt*0.8)),
  1202.         MPFROMSHORT(BKA_MAJORTAB));
  1203.     WinQueryWindowPos(                  /* Query position of dialog window */
  1204.         hwndDlg,                        /* Handle of dialog window */
  1205.         &swp);                          /* Fill with position */
  1206.     WinSetWindowPos(                    /* Set dialog window position */
  1207.         hwndDlg,                        /* Handle of dialog window */
  1208.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  1209.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  1210.                                         /* Now initialize all notebook page dialogs
  1211.                                            by posting to 1st page */
  1212.     WinPostMsg(nbPINotebookPage[PAGE_1].hwndPINBPage, WM_SETUPNOTEBOOKPAGES, (MPARAM)NULL, (MPARAM)NULL);
  1213.     break;
  1214.     }
  1215.  
  1216. case WM_HELP:                           /* Help pressed */
  1217.     {
  1218.     ULONG   ulPageId, ulPage;
  1219.     ULONG   ulHelp[]={PIID_PAGE1, PIID_PAGE2, PIID_PAGE3, PIID_PAGE4, PIID_PAGE5};
  1220.  
  1221.     ulPageId=(ULONG)WinSendMsg(hwndNB,  /* Query the currently active page */
  1222.         BKM_QUERYPAGEID,
  1223.         MPFROMLONG(0),                  /* Location page ID, ignored if */
  1224.                                         /* Page ID is BKA_TOP */
  1225.         MPFROM2SHORT(BKA_TOP, BKA_MAJOR));
  1226.     for(ulPage=0; nbPINotebookPage[ulPage].pDialogWndProc!=NULL; ulPage++)
  1227.         if(nbPINotebookPage[ulPage].ulIDPage==ulPageId)
  1228.             if(hwndHelp!=NULLHANDLE) WinSendMsg(
  1229.                 hwndHelp,               /* Help window */
  1230.                 HM_DISPLAY_HELP,        /* Display a help panel */
  1231.                                         /* Panel ID in ressource file */
  1232.                 MPFROMSHORT(ulHelp[ulPage]),
  1233.                 HM_RESOURCEID);         /* MP1 points to the help window identity */
  1234.     }
  1235.     break;
  1236.  
  1237. case WM_COMMAND:                        /* Button pressed */
  1238.     switch(SHORT1FROMMP(mp1))
  1239.     {
  1240.     case DID_OK:                        /* Enter key pressed */
  1241. /*                                                                                      *\
  1242.  * Query the Program Title, Filename, Parameters and DOS Settings and copy them to the  *
  1243.  * corresponding entries in the StartSession structure.                                 *
  1244. \*                                                                                      */
  1245.         WinQueryWindowText(             /* Query data entered in Program title entry */
  1246.             WinWindowFromID(nbPINotebookPage[PAGE_1].hwndPINBPage, PIEF_PROGRAMTITLE),
  1247.                                         /* into SessionData structure */
  1248.             sizeof(SessionData.PgmTitle),
  1249.             SessionData.PgmTitle);
  1250.         WinQueryWindowText(             /* Query data entered in Path and Filename entry */
  1251.             WinWindowFromID(nbPINotebookPage[PAGE_1].hwndPINBPage, PIEF_PATHFILENAME),
  1252.                                         /* into SessionData structure */
  1253.             sizeof(SessionData.PgmName),
  1254.             SessionData.PgmName);
  1255.         WinQueryWindowText(             /* Query data entered in working Directory entry */
  1256.             WinWindowFromID(nbPINotebookPage[PAGE_1].hwndPINBPage, PIEF_DIRECTORY),
  1257.                                         /* into SessionData structure */
  1258.             sizeof(SessionData.PgmDirectory),
  1259.             SessionData.PgmDirectory);
  1260.         WinQueryWindowText(         /* Query data entered in Parameters entry */
  1261.             WinWindowFromID(nbPINotebookPage[PAGE_1].hwndPINBPage, PIEF_PARAMETERS),
  1262.                                         /* into SessionData structure */
  1263.             sizeof(SessionData.PgmInputs),
  1264.             SessionData.PgmInputs);
  1265.         WinQueryWindowText(             /* Query data entered in DOS Settings MLE */
  1266.             WinWindowFromID(nbPINotebookPage[PAGE_1].hwndPINBPage, PIMLE_DOSSETTINGS),
  1267.                                         /* into SessionData structure */
  1268.             sizeof(SessionData.PgmDosSettings),
  1269.             SessionData.PgmDosSettings);
  1270. /*                                                                                      *\
  1271.  * Query the Program Type radiobuttons and set the corresponding bit into the           *
  1272.  * StartSession structure. No change or the default selection are preselected during    *
  1273.  * WM_INITDLG. It must be one of them set, so we don't need else parts for if-else.     *
  1274. \*                                                                                      */
  1275.                                         /* Program type: WPS default */
  1276.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_SHELL))
  1277.             SessionData.SessionType=SSF_TYPE_DEFAULT;
  1278.                                         /* Program type: OS/2 Fullscreen */
  1279.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_OS2FULLSCREEN))
  1280.             SessionData.SessionType=SSF_TYPE_FULLSCREEN;
  1281.                                         /* Program type: OS/2 Window */
  1282.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_OS2WINDOW))
  1283.             SessionData.SessionType=SSF_TYPE_WINDOWABLEVIO;
  1284.                                         /* Program type: PM */
  1285.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_PM))
  1286.             SessionData.SessionType=SSF_TYPE_PM;
  1287.                                         /* Program type: DOS Fullscreen */
  1288.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_DOSFULLSCREEN))
  1289.             SessionData.SessionType=SSF_TYPE_VDM;
  1290.                                         /* Program type: DOS Window */
  1291.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_DOSWINDOW))
  1292.             SessionData.SessionType=SSF_TYPE_WINDOWEDVDM;
  1293.                                         /* Program type: WPS Object */
  1294.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_WPSOBJECT))
  1295.             SessionData.SessionType=SSF_TYPE_WPSOBJECT;
  1296.                                         /* Program type: WIN-OS2 session. Type can then be
  1297.                                            queried from WIN-OS2 session radiobuttons */
  1298.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_WINOS2))
  1299.             {
  1300.             if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_WINREAL))
  1301.                 SessionData.SessionType=PROG_WINDOW_REAL;
  1302.             if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_WINSTANDARD))
  1303.                 SessionData.SessionType=PROG_WINDOW_PROT;
  1304.             if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_2].hwndPINBPage, PIRB_WIN386ENHANCED))
  1305.                 SessionData.SessionType=PROG_31_ENH;
  1306.             }
  1307. /*                                                                                      *\
  1308.  * Query Program Style radiobuttons and set the corresponding bits in the StartSession  *
  1309.  * structure. No change or the default selection are preselected during WM_INITDLG.     *
  1310. \*                                                                                      */
  1311.                                         /* Program style: Maximized */
  1312.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndPINBPage, PIRB_MAXIMIZED))
  1313.             SessionData.PgmControl|=SSF_CONTROL_MAXIMIZE;
  1314.         else
  1315.             SessionData.PgmControl&=(~SSF_CONTROL_MAXIMIZE);
  1316.                                         /* Program style: Minimized */
  1317.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndPINBPage, PIRB_MINIMIZED))
  1318.             SessionData.PgmControl|=SSF_CONTROL_MINIMIZE;
  1319.         else
  1320.             SessionData.PgmControl&=(~SSF_CONTROL_MINIMIZE);
  1321.                                         /* Program style: Invisible */
  1322.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndPINBPage, PIRB_INVISIBLE))
  1323.             SessionData.PgmControl|=SSF_CONTROL_INVISIBLE;
  1324.         else
  1325.             SessionData.PgmControl&=(~SSF_CONTROL_INVISIBLE);
  1326.                                         /* Program style: No autoclose */
  1327.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndPINBPage, PIRB_NOAUTOCLOSE))
  1328.             SessionData.PgmControl|=SSF_CONTROL_NOAUTOCLOSE;
  1329.         else
  1330.             SessionData.PgmControl&=(~SSF_CONTROL_NOAUTOCLOSE);
  1331.                                         /* Program style: Background */
  1332.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndPINBPage, PIRB_BACKGROUND))
  1333.             SessionData.FgBg|=SSF_FGBG_BACK;
  1334.         else
  1335.             SessionData.FgBg&=(~SSF_FGBG_BACK);
  1336. /*                                                                                      *\
  1337.  * Query Size & Position radiobutton, set the corresponding bit, and load the values    *
  1338.  * from the corresponding entryfields for the StartSession structure.                   *
  1339. \*                                                                                      */
  1340.         {
  1341.         UCHAR   Buffer[6];              /* Prefix, 4 numbers, \0 */
  1342.  
  1343.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_3].hwndPINBPage, PIRB_SIZEPOSITION))
  1344.             SessionData.PgmControl|=SSF_CONTROL_SETPOS;
  1345.         else
  1346.             SessionData.PgmControl&=(~SSF_CONTROL_SETPOS);
  1347.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_3].hwndPINBPage, PIEF_X), sizeof(Buffer), Buffer);
  1348.         SessionData.InitXPos=(SHORT)atol(Buffer);
  1349.         if(SessionData.InitXPos<HookParameters.VirtualDesktopMin.x)
  1350.             SessionData.InitXPos=HookParameters.VirtualDesktopMin.x;
  1351.         if(SessionData.InitXPos>2*HookParameters.VirtualDesktopMax.x)
  1352.             SessionData.InitXPos=HookParameters.VirtualDesktopMax.x;
  1353.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_3].hwndPINBPage, PIEF_Y), sizeof(Buffer), Buffer);
  1354.         SessionData.InitYPos=(SHORT)atol(Buffer);
  1355.         if(SessionData.InitYPos<HookParameters.VirtualDesktopMin.y)
  1356.             SessionData.InitYPos=HookParameters.VirtualDesktopMin.y;
  1357.         if(SessionData.InitYPos>2*HookParameters.VirtualDesktopMax.y)
  1358.             SessionData.InitYPos=HookParameters.VirtualDesktopMax.y;
  1359.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_3].hwndPINBPage, PIEF_XSIZE), sizeof(Buffer), Buffer);
  1360.         SessionData.InitXSize=(USHORT)atol(Buffer);
  1361.         if(SessionData.InitXSize<0) SessionData.InitXSize*=-1;
  1362.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_3].hwndPINBPage, PIEF_YSIZE), sizeof(Buffer), Buffer);
  1363.         SessionData.InitYSize=(USHORT)atol(Buffer);
  1364.         if(SessionData.InitYSize<0) SessionData.InitYSize*=-1;
  1365. /*                                                                                      *\
  1366.  * Query Hotkey settings notebook page                                                  *
  1367. \*                                                                                      */
  1368.         {
  1369.         UCHAR   ucBuffer[]=" ";
  1370.  
  1371.         SessionData.SwpFlag=0;          /* Assume no flags, which will now be corrected */
  1372.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_4].hwndPINBPage, PIRB_WSMAXIMIZED))
  1373.             SessionData.SwpFlag=SWP_MAXIMIZE;
  1374.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_4].hwndPINBPage, PIRB_WSRESTORE))
  1375.             SessionData.SwpFlag=SWP_RESTORE;
  1376.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_4].hwndPINBPage, PICB_DONTMOVE))
  1377.             SessionData.SwpFlag|=SWP_NOMOVE;
  1378.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_4].hwndPINBPage, PIRB_CTRL))
  1379.             SessionData.KeyData.usFlags=KC_CTRL;
  1380.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_4].hwndPINBPage, PIRB_ALT))
  1381.             SessionData.KeyData.usFlags=KC_ALT;
  1382.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_4].hwndPINBPage, PICBX_HOTKEY),
  1383.             sizeof(ucBuffer), ucBuffer);
  1384.                                         /* If no hotkey is contained in the hotkey combobox
  1385.                                            none is available or it is disabled ignore hotkey feature */
  1386.         if(!strcmp(ucBuffer, "") ||
  1387.             !WinQueryButtonCheckstate(nbPINotebookPage[PAGE_4].hwndPINBPage, PICB_HOTKEYENABLED))
  1388.             {
  1389.             SessionData.KeyData.usFlags=0;
  1390.             SessionData.KeyData.usCh=0;
  1391.             }
  1392.         else                            /* Mark the selected key as used */
  1393.             {
  1394.             KEYDATA     *pKeyData;
  1395.             ULONG       ulTemp1;
  1396.  
  1397.             SessionData.KeyData.usCh=(USHORT)ucBuffer[0];
  1398.             pKeyData=KeyData;           /* Point to Hotkey control structure */
  1399.                                         /* Loop for all keys and set used one */
  1400.             for(ulTemp1=0; ulTemp1<(sizeof(KeyData)/sizeof(KEYDATA)); pKeyData++, ulTemp1++)
  1401.                 {
  1402.                                         /* Set current key to used */
  1403.                 if((pKeyData->usCh==SessionData.KeyData.usCh)  &&
  1404.                     (pKeyData->usFlags==SessionData.KeyData.usFlags))
  1405.                     {
  1406.                     pKeyData->bUsed=TRUE;
  1407.                     pKeyData->pMenuData=SessionData.KeyData.pMenuData;
  1408.                     }
  1409.                 }
  1410.             }
  1411.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_4].hwndPINBPage, PIEF_SESSIONTITLE),
  1412.             sizeof(SessionData.WindowTitle), SessionData.WindowTitle);
  1413.         if(!strcmp(SessionData.WindowTitle, ""))
  1414.             strcpy(SessionData.WindowTitle, SessionData.PgmTitle);
  1415.         }
  1416. /*                                                                                      *\
  1417.  * Query Program Priority radiobuttons and set the corresponding bits in the            *
  1418.  * StartSession structure. The default priority is No-Change. The listbox is also       *
  1419.  * queried and the Delta Priority is also set in the StartSession structure. It must be *
  1420.  * one of the radiobuttons, so else part of if-else is not required.                    *
  1421. \*                                                                                      */
  1422.                                         /* Program Priority: No-Change */
  1423.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_5].hwndPINBPage, PIRB_NOCHANGE))
  1424.             SessionData.PriorityClass=PRTYC_NOCHANGE;
  1425.                                         /* Program Priority: Idle-time */
  1426.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_5].hwndPINBPage, PIRB_IDLETIME))
  1427.             SessionData.PriorityClass=PRTYC_IDLETIME;
  1428.                                         /* Program Priority: Regular */
  1429.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_5].hwndPINBPage, PIRB_REGULAR))
  1430.             SessionData.PriorityClass=PRTYC_REGULAR;
  1431.                                         /* Program Priority: Time-critical */
  1432.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_5].hwndPINBPage, PIRB_TIMECRITICAL))
  1433.             SessionData.PriorityClass=PRTYC_TIMECRITICAL;
  1434.                                         /* Program Priority: Server */
  1435.         if(WinQueryButtonCheckstate(nbPINotebookPage[PAGE_5].hwndPINBPage, PIRB_FOREGROUNDSERVER))
  1436.             SessionData.PriorityClass=PRTYC_FOREGROUNDSERVER;
  1437.                                         /* Query index of selected item on correct it */
  1438.         WinQueryWindowText(WinWindowFromID(nbPINotebookPage[PAGE_5].hwndPINBPage, PIEF_PRIORITYDELTA),
  1439.             sizeof(Buffer), Buffer);
  1440.         SessionData.PriorityDelta=(SHORT)atol(Buffer);
  1441.         }
  1442.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  1443.         break;
  1444.  
  1445.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  1446.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  1447.         break;
  1448.  
  1449.     default:
  1450.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1451.     }
  1452.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  1453.     break;
  1454.  
  1455. default:                                /* Default window procedure must be called */
  1456.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1457. }
  1458. return((MRESULT)FALSE);                 /* We have handled the message */
  1459. }
  1460.  
  1461.  
  1462. /*--------------------------------------------------------------------------------------*\
  1463.  * This dialog procedure handles the subclassed PC/2 - Program Installation dialog.     *
  1464.  * Req:                                                                                 *
  1465.  *      SessionData ... a structure of type SESSIONDATA where the information entered   *
  1466. \*--------------------------------------------------------------------------------------*/
  1467. MRESULT  EXPENTRY PI_SubclassedDialogProcedure(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  1468. {
  1469. PDRAGINFO       pDragInfo;              /* Pointer to DRAGINFO structure */
  1470. PDRAGITEM       pDragItem;              /* Pointer to DRAGITEM structure */
  1471.  
  1472. switch(msg)
  1473. {
  1474. /*                                                                                      *\
  1475.  * Allow objects to be dropped on dialog box to add first dragitem as an application.   *
  1476. \*                                                                                      */
  1477. case DM_DRAGOVER:
  1478.     pDragInfo = (PDRAGINFO)mp1;         /* Get the pointer to the DRAGINFO structure */
  1479.                                         /* Access the structure */
  1480.     if(DrgAccessDraginfo(pDragInfo)==FALSE) break;
  1481.                                         /* Get the first itemp of the item(s) dragged
  1482.                                            onto dialog window */
  1483.     pDragItem = DrgQueryDragitemPtr(pDragInfo, 0);
  1484.     if(pDragInfo->cditem!=1)
  1485.                                         /* Don't allow dropping of more than one item */
  1486.         return(MPFROM2SHORT(DOR_NODROP, DO_UNKNOWN));
  1487.     else
  1488.                                         /* Allow drop of undefined operation onto dialog window */
  1489.         return(MPFROM2SHORT(DOR_DROP, DO_UNKNOWN));
  1490.  
  1491. case DM_DROP:
  1492.     {
  1493.     UCHAR       ucBuffer[256];
  1494.     UCHAR       ucObjectType[256];
  1495.     UCHAR       *pucBuffer;
  1496.  
  1497.     pDragInfo = (PDRAGINFO)mp1;         /* Get the pointer to the DRAGINFO structure */
  1498.                                         /* Access the structure */
  1499.     if(DrgAccessDraginfo(pDragInfo)==FALSE) break;
  1500.                                         /* Get the first itemp of the item(s) dragged
  1501.                                            onto dialog window */
  1502.     pDragItem = DrgQueryDragitemPtr(pDragInfo, 0);
  1503.                                         /* Query the rendering format */
  1504.     DrgQueryStrName(pDragItem->hstrRMF, sizeof(ucObjectType), ucObjectType);
  1505.                                         /* Scan for an WPS object */
  1506.     if(strstr(ucObjectType, "<DRM_OBJECT, DRF_OBJECT>")==NULL)
  1507.         {                               /* It is an application to get path and filename */
  1508.                                         /* Query path (container) */
  1509.         DrgQueryStrName(pDragItem->hstrContainerName, sizeof(ucBuffer), ucBuffer);
  1510.                                         /* Position to \0 of path */
  1511.         pucBuffer=ucBuffer+strlen(ucBuffer);
  1512.                                         /* Query filename and append it to path */
  1513.         DrgQueryStrName(pDragItem->hstrSourceName, sizeof(ucBuffer)-strlen(pucBuffer), pucBuffer);
  1514.                                         /* Now change the entryfields to the dropped object
  1515.                                            which is not a WPS object */
  1516.         InstallFilename2Dialog(hwnd, ucBuffer, FALSE);
  1517.         }
  1518.     else
  1519.         {                               /* It is an WPS Object so only get object name */
  1520.                                         /* Query filename but don't append it to path */
  1521.         DrgQueryStrName(pDragItem->hstrSourceName, sizeof(ucBuffer), ucBuffer);
  1522.                                         /* Now change the entryfields to the dropped object
  1523.                                            which is a WPS object */
  1524.         InstallFilename2Dialog(hwnd, ucBuffer, TRUE);
  1525.         }
  1526.     }
  1527.     break;
  1528.  
  1529. default:                                /* Pass all other messages to default window procedure */
  1530.     return((MRESULT)PI_ClassDialogProcedure(hwnd, msg, mp1, mp2));
  1531. }
  1532. }
  1533.  
  1534. /*--------------------------------------------------------------------------------------*\
  1535.  * This dialog procedure handles the PC/2 - Menu Installation dialog.                   *
  1536.  * Req:                                                                                 *
  1537.  *      SessionData ... a structure of type SESSIONDATA where the information entered   *
  1538.  *                      in the dialog is entered. If DID_OK is pressed this structure   *
  1539.  *                      is used to start the session.                                   *
  1540. \*--------------------------------------------------------------------------------------*/
  1541. MRESULT  EXPENTRY MI_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  1542. {
  1543. switch(msg)
  1544. {
  1545. case WM_INITDLG:
  1546.     {
  1547.     SWP         swp;
  1548.  
  1549.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  1550.     WinQueryWindowPos(                  /* Query position of dialog window */
  1551.         hwndDlg,                        /* Handle of dialog window */
  1552.         &swp);                          /* Fill with position */
  1553.     WinSetWindowPos(                    /* Set dialog window position */
  1554.         hwndDlg,                        /* Handle of dialog window */
  1555.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  1556.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  1557. /*                                                                                      *\
  1558.  * Set the maximum number of chars accepted from the entryfield (thus overwriting the   *
  1559.  * default number of 63.                                                                *
  1560. \*                                                                                      */
  1561.     WinSendDlgItemMsg(                  /* Send message to dialog window */
  1562.         hwndDlg,                        /* Handle of dialog window */
  1563.         MIEF_MENUTITLE,                 /* Program submenu title entryfield */
  1564.         EM_SETTEXTLIMIT,                /* Set text limit to 60 */
  1565.         MPFROMSHORT(MAXNAMEL),
  1566.         (MPARAM)NULL);                  /* No additional parameter */
  1567.     WinSetDlgItemText(                  /* Set text of title entryfield */
  1568.         hwndDlg, MIEF_MENUTITLE, SessionData.PgmTitle);
  1569.     break;
  1570.     }
  1571.  
  1572. case WM_HELP:                           /* Help pressed */
  1573.     if(hwndHelp!=NULLHANDLE) WinSendMsg(
  1574.         hwndHelp,                       /* Help window */
  1575.         HM_DISPLAY_HELP,                /* Display a help panel */
  1576.         MPFROMSHORT(MIID_MENUDIALOG),   /* Panel ID in ressource file */
  1577.         HM_RESOURCEID);                 /* MP1 points to the help window identity */
  1578.     break;
  1579.  
  1580. case WM_COMMAND:                        /* Button pressed */
  1581.     switch(SHORT1FROMMP(mp1))
  1582.     {
  1583.     case DID_OK:                        /* Enter key pressed */
  1584. /*                                                                                      *\
  1585.  * Query the Submenu Title and copy it to the corresponding entry in the StartSession   *
  1586.  * structure.                                                                           *
  1587. \*                                                                                      */
  1588.         WinQueryWindowText(             /* Query data entered in Submenu title entry */
  1589.             WinWindowFromID(hwndDlg, MIEF_MENUTITLE),
  1590.                                         /* into SessionData structure */
  1591.             sizeof(SessionData.PgmTitle),
  1592.             SessionData.PgmTitle);
  1593.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  1594.         break;
  1595.  
  1596.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  1597.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  1598.         break;
  1599.  
  1600.     default:
  1601.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1602.     }
  1603.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  1604.     break;
  1605.  
  1606. default:                                /* Default window procedure must be called */
  1607.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1608. }
  1609. return((MRESULT)FALSE);                 /* We have handled the message */
  1610. }
  1611.  
  1612.  
  1613. /*--------------------------------------------------------------------------------------*\
  1614.  * This dialog procedure handles the PC/2 - Control Addition dialog.                    *
  1615.  * Req:                                                                                 *
  1616.  *      SessionData ... a structure of type SESSIONDATA where the control style         *
  1617.  *                      selected in the dialog is entered. If DID_OK is pressed this    *
  1618.  *                      structure is used to add the control entries to the Popup-menu. *
  1619. \*--------------------------------------------------------------------------------------*/
  1620. MRESULT  EXPENTRY MD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  1621. {
  1622. switch(msg)
  1623. {
  1624. case WM_INITDLG:
  1625.     {
  1626.     SWP         swp;
  1627.     ULONG       ulid;
  1628.     ULONG       ulidCopy;
  1629.                                         /* Sort radiobuttons as the Menuentry IDs are
  1630.                                            sorted */
  1631.     USHORT      usChild2Control[]={MDRB_CTRL_CONFIGMENU, MDRB_CTRL_ABOUT, MDRB_CTRL_EXIT,
  1632.                                    MDRB_CTRL_SHUTDOWN, MDRB_CTRL_CONFIGDESKTOP,
  1633.                                    MDRB_CTRL_HELP};
  1634.  
  1635.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  1636.     WinQueryWindowPos(                  /* Query position of dialog window */
  1637.         hwndDlg,                        /* Handle of dialog window */
  1638.         &swp);                          /* Fill with position */
  1639.     WinSetWindowPos(                    /* Set dialog window position */
  1640.         hwndDlg,                        /* Handle of dialog window */
  1641.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  1642.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  1643.     for(ulid=ID_CONFIGDIALOG; ulid<=ID_HELP; ulid++)
  1644.         {
  1645.         ulidCopy=ulid;                  /* Copy because SearchItem() changes passed ID */
  1646.                                         /* Search in the linked list for entry ulid */
  1647.         if((SearchItem(pPopupMenu, &ulidCopy))!=NULL)
  1648.                                         /* Disable and show 1 Control child windows
  1649.                                            according to its id if id was found */
  1650.             DisableDialogItem(hwndDlg, &usChild2Control[ulid-ID_CONFIGDIALOG],
  1651.                 1, WS_VISIBLE | WS_DISABLED);
  1652.         }
  1653.                                         /* Select Separator RB because this is the only
  1654.                                            one selectable all times */
  1655.     WinSendDlgItemMsg(hwndDlg, MDRB_CTRL_SEPARATOR, BM_SETCHECK,
  1656.         MPFROMSHORT(TRUE), (MPARAM)NULL);
  1657.     break;
  1658.     }
  1659.  
  1660. case WM_HELP:                           /* Help pressed */
  1661.     if(hwndHelp!=NULLHANDLE) WinSendMsg(
  1662.         hwndHelp,                       /* Help window */
  1663.         HM_DISPLAY_HELP,                /* Display a help panel */
  1664.                                         /* Panel ID in ressource file */
  1665.         MPFROMSHORT(MDID_CONTROLDIALOG),
  1666.         HM_RESOURCEID);                 /* MP1 points to the help window identity */
  1667.     break;
  1668.  
  1669. case WM_COMMAND:                        /* Button pressed */
  1670.     switch(SHORT1FROMMP(mp1))
  1671.     {
  1672.     case DID_OK:                        /* Enter key pressed */
  1673. /*                                                                                      *\
  1674.  * Query through all radiabuttons for the control style the user has selected. Write    *
  1675.  * the corresponding string name into the  SessionData.PgmTitle field.                  *
  1676. \*                                                                                      */
  1677.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_CONFIGMENU))
  1678.             strcpy(SessionData.PgmTitle, CTRL_CONFIGMENU);
  1679.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_CONFIGDESKTOP))
  1680.             strcpy(SessionData.PgmTitle, CTRL_CONFIGDESKTOP);
  1681.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_ABOUT))
  1682.             strcpy(SessionData.PgmTitle, CTRL_ABOUT);
  1683.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_SHUTDOWN))
  1684.             strcpy(SessionData.PgmTitle, CTRL_SHUTDOWN);
  1685.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_HELP))
  1686.             strcpy(SessionData.PgmTitle, CTRL_HELP);
  1687.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_EXIT))
  1688.             strcpy(SessionData.PgmTitle, CTRL_EXIT);
  1689.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_SEPARATOR))
  1690.             strcpy(SessionData.PgmTitle, CTRL_SEPARATOR);
  1691.         if(WinQueryButtonCheckstate(hwndDlg, MDRB_CTRL_BRKSEPARATOR))
  1692.             strcpy(SessionData.PgmTitle, CTRL_BREAKSEPARATOR);
  1693.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  1694.         break;
  1695.  
  1696.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  1697.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  1698.         break;
  1699.  
  1700.     default:
  1701.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1702.     }
  1703.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  1704.     break;
  1705.  
  1706. default:                                /* Default window procedure must be called */
  1707.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1708. }
  1709. return((MRESULT)FALSE);                 /* We have handled the message */
  1710. }
  1711.  
  1712.  
  1713. /*--------------------------------------------------------------------------------------*\
  1714.  * This dialog procedure handles the PC/2 - ShutDown OS/2 dialog.                       *
  1715.  * Req: none                                                                            *
  1716. \*--------------------------------------------------------------------------------------*/
  1717. MRESULT  EXPENTRY SD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  1718. {
  1719. switch(msg)
  1720. {
  1721. case WM_INITDLG:
  1722.     {
  1723.     SWP         swp;
  1724.  
  1725.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  1726.     WinQueryWindowPos(                  /* Query position of dialog window */
  1727.         hwndDlg,                        /* Handle of dialog window */
  1728.         &swp);                          /* Fill with position */
  1729.                                         /* Load before ShutDown info */
  1730.     WinSetDlgItemText(hwndDlg, SDID_SHUTDOWNMESSAGE, 
  1731.         "All disk activity will be suspended. After all disk activity has been stopped, "\
  1732.         "it is safe to power off or reset your system.");
  1733.     WinSetWindowPos(                    /* Set dialog window position */
  1734.         hwndDlg,                        /* Handle of dialog window */
  1735.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  1736.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  1737.     WinPostMsg(hwndDlg, WM_SHUTDOWN, NULL, NULL);
  1738.     break;
  1739.     }
  1740.  
  1741. /*                                                                                      *\
  1742.  * Syntax: WM_SHUTDOWN, NULL, NULL                                                      *
  1743. \*                                                                                      */
  1744. case WM_SHUTDOWN:
  1745. /*                                                                                      *\
  1746.  * Wait for 1 seconds and then shut down OS/2.                                          *
  1747. \*                                                                                      */
  1748.     DosSleep(01000);
  1749.     DosShutdown(0);
  1750.                                         /* Load after ShutDown info */
  1751.     WinSetDlgItemText(hwndDlg, SDID_SHUTDOWNMESSAGE,
  1752.         "All disk activity has been stopped. It is now safe to power off or reset "\
  1753.         "your system. ");
  1754.     break;
  1755.  
  1756. case WM_COMMAND:                        /* Eat up keys to avoid dismission of dialog with
  1757.                                            ESC key */
  1758.     return((MRESULT)TRUE);
  1759.  
  1760. default:                                /* Default window procedure must be called */
  1761.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1762. }
  1763. return((MRESULT)FALSE);                 /* We have handled the message */
  1764. }
  1765.  
  1766. /*--------------------------------------------------------------------------------------*\
  1767.  * This dialog procedure handles the PC/2 - Startup Parameters dialog.                  *
  1768.  * Req: *PgmInputs .....A pointer to a string of commandline params of an application   *
  1769.  *                      via mp2                                                         *
  1770. \*--------------------------------------------------------------------------------------*/
  1771. MRESULT  EXPENTRY SU_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  1772. {
  1773. static COMMANDLINEPARAMS        *pCLPParams;
  1774.  
  1775. switch(msg)
  1776. {
  1777. case WM_INITDLG:
  1778.     {
  1779.     UCHAR       ucBuffer[EF_SIZE255+1];
  1780.  
  1781.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  1782.     pCLPParams=PVOIDFROMMP(mp2);
  1783. /*                                                                                      *\
  1784.  * Load text from CLPParams into the dialog box text fields, and set the text limit of  *
  1785.  * the entryfield to 127.                                                               *
  1786. \*                                                                                      */
  1787.                                         /* Program to be started information text field */
  1788.     WinSetDlgItemText(hwndDlg, SUTF_STARTUPPROGRAM, pCLPParams->ucPgmTitle);
  1789.     sprintf(ucBuffer, "%s[...] %s", pCLPParams->ucPBefore, pCLPParams->ucPAfter);
  1790.                                         /* User information text field */
  1791.     WinSetDlgItemText(hwndDlg, SUTF_STARTUPINFO, pCLPParams->ucPUser);
  1792.                                         /* Current parameters text field */
  1793.     WinSetDlgItemText(hwndDlg, SUTF_STARTUPPARAMETERS, ucBuffer);
  1794.     WinSendDlgItemMsg(hwndDlg, SUEF_STARTUPPARAMETERS, EM_SETTEXTLIMIT,
  1795.         MPFROMSHORT(MAXNAMEL), (MPARAM)NULL);
  1796.     break;
  1797.     }
  1798.  
  1799. case WM_HELP:                           /* Help pressed */
  1800.     if(hwndHelp!=NULLHANDLE) WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
  1801.         MPFROMSHORT(SUID_STARTUPDIALOG), HM_RESOURCEID);
  1802.     break;
  1803.  
  1804. case WM_COMMAND:                        /* Button pressed */
  1805.     switch(SHORT1FROMMP(mp1))
  1806.     {
  1807.     case DID_OK:                        /* Enter key pressed */
  1808.         WinQueryWindowText(WinWindowFromID(hwndDlg, SUEF_STARTUPPARAMETERS),
  1809.             sizeof(pCLPParams->ucPUser), pCLPParams->ucPUser);
  1810.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  1811.         break;
  1812.  
  1813.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  1814.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  1815.         break;
  1816.  
  1817.     default:
  1818.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1819.     }
  1820.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  1821.     break;
  1822.  
  1823. default:                                /* Default window procedure must be called */
  1824.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  1825. }
  1826. return((MRESULT)FALSE);                 /* We have handled the message */
  1827. }
  1828.  
  1829. /*--------------------------------------------------------------------------------------*\
  1830.  * This dialog procedure handles the PC/2 - Resort dialog.                              *
  1831. \*--------------------------------------------------------------------------------------*/
  1832. MRESULT  EXPENTRY RD_DialogProcedure(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  1833. {
  1834. static MENUDATA *pSortedMenuData;       /* Pointer to the first element of the resorted
  1835.                                            linked list */
  1836. static MENUDATA *pParentMenuData;       /* Menuitem, which current level is a child of */
  1837. static USHORT   usChild2InitPBs[]={DID_OK};
  1838. static USHORT   usChild2MovePBs[]={DID_CANCEL};
  1839. static USHORT   usChild2OKPBs[]={RDPB_MOVE};
  1840. static BOOL     bFirstMove;
  1841. switch(msg)
  1842. {
  1843. case WM_INITDLG:
  1844.     {
  1845.     SWP         swp;
  1846.     MENUDATA    *pMDSource;             /* Pointer withing the current linked list */
  1847.  
  1848.     WinDefDlgProc(hwndDlg, msg, mp1, mp2);
  1849.     WinQueryWindowPos(                  /* Query position of dialog window */
  1850.         hwndDlg,                        /* Handle of dialog window */
  1851.         &swp);                          /* Fill with position */
  1852.     WinSetWindowPos(                    /* Set dialog window position */
  1853.         hwndDlg,                        /* Handle of dialog window */
  1854.         HWND_TOP,                       /* Position on top and center of DESKTOP */
  1855.         (swpScreen.cx-swp.cx)/2, (swpScreen.cy-swp.cy)/2, 0, 0, SWP_MOVE);
  1856. /*                                                                                      *\
  1857.  * Disable OK pushbutton, until all items have been moved. Get the first element of the *
  1858.  * current level of the linked list which will be resorted. Add all Menuitems of the    *
  1859.  * current level of the linked list to the source listbox. Save the parent Menuitem,    *
  1860.  * from where the current level is a child of.                                          *
  1861. \*                                                                                      */
  1862.     bFirstMove=FALSE;                   /* We didn't make any sort before */
  1863.     pSortedMenuData=NULL;               /* Pointer of resorted linked list points to a non
  1864.                                            available Menuitem */
  1865.                                         /* Disable and show OK pushbutton */
  1866.     DisableDialogItem(hwndDlg, usChild2InitPBs,
  1867.         sizeof(usChild2InitPBs)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  1868.     if(pMenuData==pPopupMenu)           /* Is current level is the root of all levels ? */
  1869.         pParentMenuData=NULL;           /* Yes, then parent Menuitem is NULL */
  1870.     else                                /* No, then get parent Menuitem */
  1871.         pParentMenuData=pMenuData->Back;
  1872.     pMDSource=pMenuData;                /* Get first element of linked list */
  1873.     do                                  /* Add current level of Menuitems to the source listbox */
  1874.     {
  1875.         if(pMDSource->Item==ENTRYSUBMENU) /* It is a Submenu */
  1876.             {
  1877.             UCHAR       ucBuffer[MAXNAMEL+4];
  1878.                                         /* Add >> for a Submenu */
  1879.             sprintf(ucBuffer, "%s >>", pMDSource->PgmTitle);
  1880.                                         /* Insert Menuitem at the end of the listbox */
  1881.             WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_INSERTITEM,
  1882.                 MPFROMSHORT(LIT_END), MPFROMP(ucBuffer));
  1883.             }
  1884.                                         /* It's a Menuitem or Control */
  1885.         if((pMDSource->Item==ENTRYMENUITEM) || (pMDSource->Item==ENTRYCONTROL))
  1886.             WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_INSERTITEM,
  1887.                 MPFROMSHORT(LIT_END), MPFROMP(pMDSource->PgmTitle));
  1888.                                         /* It may also be an empty entry, but then we
  1889.                                            ignore it, because it must be filled with
  1890.                                            Menuitem or Submenu data first */
  1891.         if(pMDSource->Next!=NULL)       /* Get through linked list without diving into
  1892.                                            Submenus */
  1893.                 pMDSource=pMDSource->Next;
  1894.         else break;                     /* We're at the end of the linked list */
  1895.     }while(TRUE);
  1896.     break;
  1897.     }
  1898.  
  1899. case WM_HELP:                           /* Help pressed */
  1900.     if(hwndHelp!=NULLHANDLE) WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
  1901.         MPFROMSHORT(RDID_RESORTDIALOG), HM_RESOURCEID);
  1902.     break;
  1903.  
  1904. case WM_COMMAND:                        /* Button pressed */
  1905.     switch(SHORT1FROMMP(mp1))
  1906.     {
  1907.     case RDPB_MOVE:                     /* Move pushbutton */
  1908.         {
  1909.         MENUDATA        *pMDSource;     /* Walk through current linked list */
  1910.                                         /* Walk through destination linked list */
  1911.         MENUDATA        *pMDDestination;
  1912.         SHORT           sCount;
  1913.  
  1914. /*                                                                                      *\
  1915.  * For the first resort operation, disable the Cancel pushbutton.                       *
  1916. \*                                                                                      */
  1917.         if(bFirstMove==FALSE)           /* After the first move operation, disable the
  1918.                                            Cancel pushbutton */
  1919.             {
  1920.             bFirstMove=TRUE;            /* We make now the first move */
  1921.             DisableDialogItem(hwndDlg, usChild2MovePBs,
  1922.                 sizeof(usChild2MovePBs)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  1923.             }
  1924. /*                                                                                      *\
  1925.  * Now get the selected Menuitem of the source listbox, delete it from the listbox. If  *
  1926.  * the source listbox is now empty, reenable the OK pushbutton again.                   *
  1927. \*                                                                                      */
  1928.                                         /* Query the selected Menuitem from the source listbox */
  1929.         sCount=(SHORT)WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_QUERYSELECTION,
  1930.             MPFROMSHORT(LIT_FIRST), (MPARAM)NULL);
  1931.         if(sCount==LIT_NONE)            /* If no item selected ignore this button */
  1932.             return((MRESULT)FALSE);
  1933.         {
  1934.         UCHAR   ucBuffer[MAXNAMEL+4];
  1935.         SHORT   usItems;
  1936.                                         /* Query the text of the selected Menuitem from the
  1937.                                            source listbox */
  1938.         WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_QUERYITEMTEXT,
  1939.             MPFROM2SHORT(sCount, sizeof(ucBuffer)), MPFROMP(ucBuffer));
  1940.                                         /* Delete the selected Menuitem from the source listbox */
  1941.         WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_DELETEITEM,
  1942.             MPFROMSHORT(sCount), (MPARAM)NULL);
  1943.                                         /* Insert the text of the selected Menuitem into the
  1944.                                            destination listbox */
  1945.         WinSendDlgItemMsg(hwndDlg, RDLB_DESTINATIONMENU, LM_INSERTITEM,
  1946.             MPFROMSHORT(LIT_END), MPFROMP(ucBuffer));
  1947.                                         /* Query the number of Menuitems from the source
  1948.                                            listbox */
  1949.         usItems=(USHORT)WinSendDlgItemMsg(hwndDlg, RDLB_SOURCEMENU, LM_QUERYITEMCOUNT,
  1950.             (MPARAM)NULL, (MPARAM)NULL);
  1951.         if(usItems==0)                  /* If now more items left, reenable OK pushbutton
  1952.                                            and disable Resort pushbutton */
  1953.             {
  1954.             DisableDialogItem(hwndDlg, usChild2InitPBs,
  1955.                 sizeof(usChild2InitPBs)/sizeof(USHORT), WS_VISIBLE);
  1956.             DisableDialogItem(hwndDlg, usChild2OKPBs,
  1957.                 sizeof(usChild2OKPBs)/sizeof(USHORT), WS_VISIBLE | WS_DISABLED);
  1958.             }
  1959.         }
  1960. /*                                                                                      *\
  1961.  * Now remove the selected Menuitem from the current linked list, by updating the       *
  1962.  * pointers according to previous or following Menuitems.                               *
  1963. \*                                                                                      */
  1964.         pMDSource=pMenuData;            /* Point to the first element of the linked list */
  1965.         for( ; sCount>0; sCount--)      /* Walk through the linked list to the selected
  1966.                                            item */
  1967.             pMDSource=pMDSource->Next;
  1968.         pMDDestination=pSortedMenuData; /* Point to the first element of the resorted linked list */
  1969.         if(pMDDestination!=NULL)        /* Walk through the resorted linked list to the
  1970.                                            last Menuitem, if there's at least one element */
  1971.             for( ; pMDDestination->Next!=NULL; pMDDestination=pMDDestination->Next);
  1972. /*                                                                                      *\
  1973.  * Now update the Popup-Menu, by moving the selected Menuitem.                          *
  1974. \*                                                                                      */
  1975.         if((pMDDestination==NULL) && (pParentMenuData==NULL))
  1976.             SetPopupMenu(MM_MOVEMENUITEM, MPFROMP(pMDSource), MPFROMP(pPopupMenu));
  1977.         if((pMDDestination==NULL) && (pParentMenuData!=NULL))
  1978.             SetPopupMenu(MM_MOVEMENUITEM, MPFROMP(pMDSource), MPFROMP(pParentMenuData));
  1979.         if(pMDDestination!=NULL)
  1980.             SetPopupMenu(MM_MOVEMENUITEM, MPFROMP(pMDSource), MPFROMP(pMDDestination));
  1981.  
  1982.         if((pMDSource->Back!=NULL) && (pMDSource->Next!=NULL))
  1983.             {                           /* Current element follows another and is followed
  1984.                                            by another element, so simple remove it by
  1985.                                            updating the pointers. Be carefull if the
  1986.                                            parent element is a Submenu where the current
  1987.                                            level is a leaf of. */
  1988.             if((pMDSource->Back)->Submenu==pMDSource)
  1989.                 {
  1990.                 (pMDSource->Back)->Submenu=pMDSource->Next;
  1991.                 pMenuData=pMDSource->Next;
  1992.                 }
  1993.             else
  1994.                 (pMDSource->Back)->Next=pMDSource->Next;
  1995.             (pMDSource->Next)->Back=pMDSource->Back;
  1996.             }
  1997.         if((pMDSource->Back!=NULL) && (pMDSource->Next==NULL))
  1998.             {                           /* Current element follows another but is the last
  1999.                                            one of the current linked list.  Be carefull if
  2000.                                            the parent element is a Submenu where the current
  2001.                                            level is a leaf of. */
  2002.                                         /* Next element of course is NULL */
  2003.             if((pMDSource->Back)->Submenu==pMDSource)
  2004.                 {
  2005.                 (pMDSource->Back)->Submenu=pMDSource->Next;
  2006.                 pMenuData=pMDSource->Next;
  2007.                 }
  2008.             else
  2009.                 (pMDSource->Back)->Next=pMDSource->Next;
  2010.             }
  2011.         if((pMDSource->Back==NULL) && (pMDSource->Next!=NULL))
  2012.             {                           /* Current element is the first one of the complete
  2013.                                            linked list, but is followed by another */
  2014.             (pMDSource->Next)->Back=NULL;
  2015.             pMenuData=pMDSource->Next;
  2016.             pPopupMenu=pMDSource->Next;
  2017.             }
  2018.         if((pMDSource->Back==NULL) && (pMDSource->Next==NULL))
  2019.             {                           /* Current element is the first one of the complete
  2020.                                            linked list, and isn't followed by another */
  2021.             pMenuData=NULL;
  2022.             pPopupMenu=NULL;
  2023.             }
  2024. /*                                                                                      *\
  2025.  * Now add the deleted Menuitem at the end of the resorted linked list, by updating the *
  2026.  * pointer of the last element to point to the deleted one.                             *
  2027. \*                                                                                      */
  2028.         if(pMDDestination==NULL)
  2029.             {                           /* If the resorted linked list is empty, add
  2030.                                            deleted element and update pointers */
  2031.             pSortedMenuData=pMDSource;
  2032.             pMDDestination=pMDSource;
  2033.             pMDDestination->Next=NULL;
  2034.             pMDDestination->Back=NULL;
  2035.             }
  2036.         else
  2037.             {                           /* If the resorted linked list isn't empty, add
  2038.                                            deleted element at the end and update pointers */
  2039.             pMDDestination->Next=pMDSource;
  2040.             pMDSource->Back=pMDDestination;
  2041.             pMDSource->Next=NULL;
  2042.             }
  2043.         }
  2044.         return((MRESULT)FALSE);         /* We don't want to close the dialog by breaking
  2045.                                            out of the switch statement */
  2046.  
  2047.     case DID_OK:                        /* Enter key pressed */
  2048. /*                                                                                      *\
  2049.  * Now replace the current linked list, which is empty as all Menuitems have been re-   *
  2050.  * moved, with the resorted linked list.                                                *
  2051. \*                                                                                      */
  2052.         if(pParentMenuData==NULL)
  2053.             {                           /* If the root of the complete linked list has been
  2054.                                            resorted, update the root pointers */
  2055.             pPopupMenu=pSortedMenuData;
  2056.             pMenuData=pPopupMenu;
  2057.             }
  2058.         else
  2059.             {                           /* If the current level has a parent Menuitem, a
  2060.                                            Submenu of course, update the current level pointers */
  2061.             pMenuData=pSortedMenuData;
  2062.             pSortedMenuData->Back=pParentMenuData;
  2063.             pParentMenuData->Submenu=pMenuData;
  2064.             }
  2065.         DialogResult=DID_OK;            /* Dialog terminated with DID_OK */
  2066.         break;
  2067.  
  2068.     case DID_CANCEL:                    /* Escape or Cancel pressed */
  2069.         DialogResult=DID_CANCEL;        /* Dialog terminated with DID_CANCEL */
  2070.         break;
  2071.  
  2072.     default:
  2073.         return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2074.     }
  2075.     WinDismissDlg(hwndDlg, TRUE);       /* Clear up dialog */
  2076.     break;
  2077.  
  2078. default:                                /* Default window procedure must be called */
  2079.     return(WinDefDlgProc(hwndDlg, msg, mp1, mp2));
  2080. }
  2081. return((MRESULT)FALSE);                 /* We have handled the message */
  2082. }
  2083.  
  2084.  
  2085.